为什么只有80分???????!!!!!!!

P1001 A+B Problem

ILIKEYSH1314 @ 2024-12-14 16:28:00

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    if(a<0&&b<0){
    long long i=0;
    while(i>a){
        i--;
    }
    long long n=0;
    while(n>b){
        n--;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a与b都小于0; 
    else if(a>0&&b<0){
    long long i=0;
    while(i<a){
        i++;
    }
    long long n=0;
    while(n>b){
        n--;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a大于0,b小于0; 
    else if(a<0&&b>0){
    long long i=0;
    while(i>a){
        i--;
    }
    long long n=0;
    while(n<b){
        n++;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a小于0, b大于0; 
    else if(a>0&&b>0){
    long long i=0;
    while(i<a){
        i++;
    }
    long long n=0;
    while(n<b){
        n++;
    }
    long long ans;
    ans=i+n;
    cout<<ans<<endl;
    return 0;
    }
    //a与b都大于0; 
 }

by LG_jyc @ 2024-12-14 16:30:28

@ILIKEYSH1314

O(n)肯定时间爆炸啊


by littlesnake @ 2024-12-14 16:30:54

……


by Retoayd @ 2024-12-14 16:31:11

666


by Crasole @ 2024-12-14 16:31:12

6666666


by ILIKEYSH1314 @ 2024-12-14 16:32:12

@LG_jyc 是WA而不是TLE


by LG_jyc @ 2024-12-14 16:33:33

@ILIKEYSH1314


by di_tie_bo_er_te @ 2024-12-19 16:59:47

太复杂了 看看我的

#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d,e,f,g;
scanf("%d%d",&a,&b);
if(1+1==2)
{
if(2+2==4)
{
if(3+3==6)
{
c=a+b;d=a+b;d=c;e=c;e=d;f=a+b;f=c;f=e;f=f+1-1+1-1;g=f;g=g+1-1+1-1+123456789-123456789;
}
}
}printf("%d\n",g);

return 0;
}

@ILIKEYSH1314


by di_tie_bo_er_te @ 2024-12-19 17:00:03

求关


by wangchenyu20140808 @ 2025-01-02 17:30:11

#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b;    
}

|