TLE的一百……

P1307 [NOIP2011 普及组] 数字反转

lyc18 @ 2022-09-12 09:19:37


#include<bits/stdc++.h>
using namespace std;
long long s[11]= {},n,k=0,m=1;
int main() {
    memset(s,0,sizeof(n));
    cin>>n;
    for(int i=1; i<=10; i++){
        s[i]=n/m%10;
        m*=10;
    }
    m=1000000000;
    for(int i=1; i<=10; i++){
        k+=s[i]*m;
        m/=10;
    }
    while(k%10==0){
        k/=10;
    } 
    cout<<k;
    return 0;
}

by OoXiao_QioO @ 2022-09-12 09:23:36

@lyc18 看在你头像的份上,我就不回答了


by Elairin176 @ 2022-09-12 09:24:05

@lyc18 最后那个应该是新加的hack数据


by _Remake_ @ 2022-09-12 09:24:29

乐 输入个0你代码就寄了


by Elairin176 @ 2022-09-12 09:26:41

@lyc18

#include<bits/stdc++.h>
using namespace std;
long long s[11]= {},n,k=0,m=1;
int main() {
    memset(s,0,sizeof(s));
    cin>>n;
    for(int i=1; i<=10; i++){
        s[i]=n/m%10;
        m*=10;
    }
    m=1000000000;
    for(int i=1; i<=10; i++){
        k+=s[i]*m;
        m/=10;
    }
    while(k%10==0&&k!=0){
        k/=10;
    } 
    cout<<k;
    return 0;
}

特判0


by lyc18 @ 2022-09-12 09:29:00

谢谢啦,各位大佬


by gongziwen @ 2022-09-12 09:33:55

@lyc18 头像危


by zhang_kevin @ 2022-09-12 09:36:27

@lyc18 个性签名危


by chenzhiyuan0923 @ 2022-09-12 12:39:21

@lyc18 emmmmmm


|