题解

74 条题解

  • 0
    @ 2016-10-05 14:36:11

    Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
    Copyright (c) 1993-2015 by Florian Klaempfl and others
    Target OS: Win32 for i386
    Compiling foo.pas
    Linking foo.exe
    20 lines compiled, 0.0 sec, 26592 bytes code, 1268 bytes data
    测试数据 #0: Accepted, time = 0 ms, mem = 808 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 808 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 808 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 808 KiB, score = 10
    测试数据 #4: Accepted, time = 15 ms, mem = 808 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 808 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 804 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 808 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 812 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 808 KiB, score = 10
    Accepted, time = 15 ms, mem = 812 KiB, score = 100
    代码
    ```pascal
    var a,t:longint;
    inp:char;
    fs:boolean;

    begin
    fs:=false;
    read(inp);
    if inp='-' then begin
    a:=0;t:=1;fs:=true;
    end else begin
    a:=ord(inp)-ord('0');t:=10;
    end;
    while not eoln do begin
    read(inp);
    inc(a,(ord(inp)-ord('0'))*t);
    t:=t*10;
    end;
    if fs then write('-');
    writeln(a);
    end.
    ```

  • 0
    @ 2016-09-24 19:32:43
    #ifndef _DEBUG
    #pragma GCC optimize(2)
    #ifdef Full_Cpp_Compiler
    #include <codecvt>
    #endif
    #include <sstream>
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <memory>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include <cmath>
    #include <queue>
    #include <cstring>
    #include <fstream>
    #include <Windows.h>
    #include <iterator>
    #include <set>
    #include <process.h>
    #include <ctime>
    #include <utility>
    #include <cctype>
    #include <bitset>
    #include <stdarg.h>
    #define max(a,b) (a>b?a:b)
    #define min(a,b) (a>b?a:b)
    #endif // _DEBUG
    
    int main() {
        std::ios_base::sync_with_stdio(false);
    
        std::string str;
        int pos;
        std::cin >> str;
        pos = str.size()-1;
        while (str[pos] == '0' || str[pos] == ' ') {
            pos--;
        }
        int end = 0;
        if (str[0] == '-') { std::cout << "-"; end = 1; }
        for (int i = pos; i >= end; i--) {
            std::cout << str[i];
        }
    #ifdef  _DEBUG
        system("pause");
    #endif //  _DEBUG
        return 0;
    }
    
  • 0
    @ 2016-08-24 21:10:26

    #include<iostream>
    using namespace std;
    int main()
    {
    int a,b;
    b=0;
    cin>>a;
    do{
    b=b*10+a%10;
    a=a/10;
    }while(a!=0);
    cout<<b;
    return 0;
    }
    此题真是水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水!

  • 0
    @ 2016-08-23 18:20:46

    Pascal超短
    var i,n:longint; s:string;
    begin
    readln(s);
    if s[1]='-' then
    begin
    write('-');
    delete(s,1,1);
    end;
    for i:=length(s) downto 2 do
    if s[i]<>'0' then break;
    if (i=2) and (s[i]='0') then n:=i-1 else n:=i;
    for i:=n downto 1 do write(s[i]);
    end.

  • 0
    @ 2016-08-19 13:06:45

    easy
    ```c++
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 500 KiB, score = 10
    Accepted, time = 0 ms, mem = 504 KiB, score = 100
    代码
    #include <cstdio>
    #include <cstring>
    char c[11];
    int begin = 1,end,s[11];
    int main() {
    memset(s,0,sizeof(s));
    scanf("%s",c+1);
    if (c[1] == '-') printf("-"),begin = 2;
    end = strlen(c+1);
    memset(s,0,sizeof(s));
    for (int i = begin;i <= end;i++) s[i] = c[i]-'0';
    int top = 10;
    while (top > 1 && !s[top]) top--;
    for (int i = top;i >= begin;i--) printf("%d",s[i]);
    return 0;
    }
    ```

    • @ 2016-08-24 21:21:49

      你的超过十一位就爆!!

    • @ 2016-08-28 11:53:55

      那你要我char c[100001];
      int begin = 1,end,s[100001];

  • 0
    @ 2016-08-17 21:30:34

    var
    s:string;
    n,i,j,ans:longint;
    t:char;
    begin
    readln(s);
    n:=length(s);
    if s[1]='-' then begin
    write('-');
    for i:=n downto 2 do begin
    if s[i]<>'0' then begin
    ans:=i;
    break;
    end;
    end;
    for i:=ans downto 2 do begin
    write(s[i]);
    end;
    exit;
    end;
    if s[i]<>'-' then begin
    for i:=n downto 1 do begin
    if s[i]<>'0' then begin
    ans:=i;
    break;
    end;
    end;
    for i:=ans downto 1 do begin
    write(s[i]);
    end;
    end;
    end.

  • 0
    @ 2016-08-02 16:57:09

    c++代码,用了点函数
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    using namespace std;

    int n,ans[20],temp=1;

    void change(int);
    void print(int);

    int main()
    {
    cin>>n;

    if (n<0){
    change(abs(n));
    print(0);
    }else{
    change(n);
    print(1);
    }

    return 0;
    }

    void change(int a)
    {
    while (a>=10){
    ans[temp]=a%10;
    a/=10;
    temp++;
    }
    ans[temp]=a;
    }

    void print(int b){
    if (b==0){
    cout<<"-";
    }
    int temp2=1;
    while (ans[temp2]==0){
    temp2++;
    }
    for (int i=temp2;i<=temp;i++){
    cout<<ans[i];
    }
    cout<<endl;
    }

  • 0
    @ 2016-07-12 16:02:56

    #include<cstdio>
    #include<iostream>
    using namespace std;
    int main(){
    long long a=0;
    cin>>a;
    if(a<0){
    a=-a;
    cout<<"-";
    }
    if(a==0){
    cout<<"0"<<endl;
    }
    while(a%10==0)
    a=a/10;
    if(a%10){
    do{
    cout<<a%10;
    a=a/10;
    }while(a);
    }
    return 0;
    }

  • 0
    @ 2016-06-26 16:07:40

    #include <cstdio>

    int main(){
    freopen("in.txt","r",stdin);
    char a[2000];
    int n=1;
    while(scanf(" %c",&a[n])==1)
    n++;
    n--;
    int flag=1,zero=1;
    if(a[1]=='-'){
    flag=0;
    printf("-");
    }

    for(int i=n;i>=2;i--){
    if(zero&&a[i]=='0')
    continue;
    printf("%c",a[i]);
    zero=0;
    }
    if(flag)
    printf("%c",a[1]);
    return 0;
    }

  • 0
    @ 2016-05-15 19:26:33
    #include<stdio.h>
    #include<iostream>
      using namespace std;
    
    int main ()
    {
        freopen("reverse.in","r",stdin);
        freopen("reverse.out","w",stdout);
        int n,f=0;
        cin>>n;
        if(n==0) cout<<0;
        else if(n<0) {n=-n;cout<<"-";goto h;}
     else 
        {
    h:  while(n!=0)
           {
                int t=n%10;
                if(t!=0||f){cout<<t;f=1;}
                n/=10;
            }
        }
        return 0;
    }
    
  • 0
    @ 2016-05-11 21:17:09

    AC留念
    pascal
    var i,j,k,l:longint;
    b:string;
    a:array[1..13] of char;
    begin
    read(b); k:=length(b);
    if ord(b[1])=45 then
    begin
    a[1]:='-';
    j:=2;
    write('-');
    end
    else j:=1;
    for i:=j to k do
    a[i]:=b[i];
    for i:=k downto j do
    begin
    if a[i]<>'0' then
    begin
    l:=i;
    end;
    if a[i]<>'0' then
    break;
    end;
    for i:=l downto j do
    write(a[i]);
    end.

  • 0
    @ 2016-04-26 16:17:07

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    int qidian(char s)
    {
    if(s!='0') return 1;
    else return 0;
    }
    main()
    {
    long long int N;
    int i,k,j,len;
    char s[15];
    scanf("%lld",&N);

    sprintf(s,"%lld",N);
    len=strlen(s);
    if(s[0]=='-') printf("-");
    for(j=len-1;;j--)
    {
    k=qidian(s[j]);
    if(k==1) break;
    if(j==1&&s[0]=='-') break;
    }
    for(i=j;i>=0;i--)
    {
    if(s[i]=='-') break;
    printf("%c",s[i]);

    }
    return 0;
    }

  • 0
    @ 2016-02-22 17:22:30
    import java.util.*;
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            StringBuilder sb = new StringBuilder();
            sb.append(sc.nextLine());
            String str = "";
            boolean isfu=sb.substring(0, 1).toString().equals("-")?true:false;
            if (isfu) 
                str = sb.reverse().substring(0, sb.length() - 1).toString();
            else
                str = sb.reverse().toString();
            if (!str.equals("0"))
                while (str.indexOf("0") == 0)
                    str =str.substring(1);
            if(isfu)
                str="-"+str;
            System.out.println(str);
        }
    }
    
  • 0
    @ 2016-02-10 21:32:50

    字符串有用吗
    var n,m:longint;
    begin
    read(n);
    m:=0;
    while abs(n)>0 do
    begin
    m:=10*m+n mod 10;
    n:=n div 10;
    end;
    write(m);
    end.

  • 0
    @ 2015-12-15 04:42:34

    晕,这么简单题被我弄复杂了,搞了老半天……

    #include<stdio.h>
    #include<string.h>
    int main()
    {
    char N[20],*p=N;
    int flag=1;
    gets(N);
    if(N[0]=='-')
    printf("-");
    strrev(N);
    while(flag)
    {
    if(*p!='0')
    flag=0;
    else
    p++;
    }
    while(*p!='\0')
    {
    if(*p!='-')
    printf("%c",*p);
    p++;
    }
    return 0;
    }

  • 0
    @ 2015-12-14 17:32:02

    AC 10题纪念

    • @ 2015-12-14 17:32:31

      var s:string;
      n,m,t,j,k:longint;
      begin
      read(s);
      if s[1]<>'-' then
      begin
      for n:=length(s) downto 1 do
      begin
      if (t=0)and(s[n]<>'0') then t:=t+1;
      if t=1 then write(s[n]);
      end;
      end
      else
      begin
      write('-');
      for n:=length(s) downto 2 do
      begin
      if (t=0)and(s[n]<>'0') then t:=t+1;
      if t=1 then write(s[n]);
      end;
      end;
      end.

  • 0
    @ 2015-10-07 08:03:46

    测试数据 #0: Accepted, time = 0 ms, mem = 800 KiB, score = 10

    测试数据 #1: Accepted, time = 1 ms, mem = 808 KiB, score = 10

    测试数据 #2: Accepted, time = 1 ms, mem = 804 KiB, score = 10

    测试数据 #3: Accepted, time = 2 ms, mem = 804 KiB, score = 10

    测试数据 #4: Accepted, time = 1 ms, mem = 804 KiB, score = 10

    测试数据 #5: Accepted, time = 0 ms, mem = 804 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 804 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 804 KiB, score = 10

    测试数据 #8: Accepted, time = 1 ms, mem = 808 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 804 KiB, score = 10

    Accepted, time = 6 ms, mem = 808 KiB, score = 100

    代码
    var s:string;
    a:array[0..10000]of longint;
    i,n:longint;
    begin
    read(s);
    n:=length(s);
    if s[1]='-'then
    begin
    write('-');
    for i:=2 to n do
    a[i]:=ord(s[i])-48;
    i:=n;
    while a[i]=0 do
    begin
    n:=n-1;i:=i-1;
    end;
    for i:=n downto 2 do
    write(a[i]);
    writeln;
    end
    else
    begin
    for i:=1 to n do
    a[i]:=ord(s[i])-48;
    i:=n;
    while a[i]=0 do
    begin
    n:=n-1;i:=i-1;
    end;
    for i:=n downto 1 do
    write(a[i]);
    writeln;
    end;
    end.

  • 0
    @ 2015-09-30 23:46:39

    字符串搞得我头晕
    #include <stdio.h>

    int main(){
    int i,l;
    char c[1000];
    scanf("%s",&c);
    for(l=0;;l++)
    if(c[l]=='\0')
    break;
    int flag=0;
    if(c[0]!='-'){
    for(i=l-1;i>=0;i--){
    if(c[i]!='0'){
    flag++;
    printf("%d",c[i]-'0');
    }

    if(c[i]=='0')
    if(flag)
    printf("%d",c[i]-'0');
    }
    }
    if(c[0]=='-'){
    printf("-");
    for(i=l-1;i>0;i--){
    if(c[i]!='0'){
    flag++;
    printf("%d",c[i]-'0');
    }

    if(c[i]=='0')
    if(flag)
    printf("%d",c[i]-'0');
    }
    }

    return 0;
    }

  • 0
    @ 2015-09-19 21:31:52

    #include<iostream>
    using namespace std;
    int main()
    {
    int k;
    bool flag=false;
    scanf("%d",&k);
    if(k<0)
    {
    printf("-");
    k=0-k;
    }
    while(k)
    {
    // 前导0
    int out;
    out = k%10;

    if(out==0 && flag)
    printf("0");
    else if(out!=0)
    {
    flag = true;
    printf("%d",out);
    }
    k/=10;
    }
    }

  • 0
    @ 2015-09-10 14:47:37

    ###水题啊

    评测状态 Accepted
    题目 P1756 数字反转
    递交时间 2015-09-10 14:46:53
    代码语言 C++
    评测机 VijosEx
    消耗时间 29 ms
    消耗内存 520 KiB
    评测时间 2015-09-10 14:46:54
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 520 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 516 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 516 KiB, score = 10
    测试数据 #3: Accepted, time = 14 ms, mem = 516 KiB, score = 10
    测试数据 #4: Accepted, time = 15 ms, mem = 512 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 516 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 516 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 512 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 516 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 512 KiB, score = 10
    Accepted, time = 29 ms, mem = 520 KiB, score = 100
    代码
    #include <iostream>
    #include <cstdio>
    #include <string.h>
    using namespace std;
    char s[20];
    int main()
    {
    scanf("%s",s);
    int len=strlen(s)-1;
    if(s[0]=='-')
    {
    printf("-");
    for(;s[len]=='0';len--);
    for(int i=len;i>=1;i--) printf("%c",s[i]);
    return 0;
    }

    if(len==0&&s[1]==0){
    printf("0");
    return 0;
    }

    for(;s[len]=='0';len--);
    for(int i=len;i>=0;i--) printf("%c",s[i]);
    }

信息

ID
1756
难度
4
分类
模拟 点击显示
标签
递交数
3911
已通过
1766
通过率
45%
被复制
22
上传者