2 条题解

  • 1
    @ 2026-7-31 18:00:24

    /* int %d longlong %lld float %f double %lf char %c char[] %s 'a'=97 'z'=122 'A'=65 'Z'=90 '0'=48 '9'=57 */ #include #include #include #include #include #include using namespace std; const int N=1e5+10; const int INF=0x3f3f3f3f; int n,x,y,a[N],b[N],c[N]; int len; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d%d",&x,&y); a[n-i]=x; b[n-i]=y; } x=0; for(int i=0;i<n;i++){ c[i]=a[i]+b[i]+x; x=c[i]/10; c[i]%=10; } len=n-1; if(x){ c[++len]=x; } for(int i=len;i>=0;i--){ printf("%d",c[i]); } return 0; }

    • -1
      @ 2024-4-5 16:53:44
      /*
      int       %d
      longlong  %lld
      float     %f
      double    %lf
      char      %c
      char[]    %s
      'a'=97
      'z'=122
      'A'=65
      'Z'=90
      '0'=48
      '9'=57
      */
      #include <iostream>
      #include <iomanip>
      #include <cmath>
      #include <cstdio>
      #include <cstring>
      #include <algorithm>
      using namespace std;
      const int N=1e5+10;
      const int INF=0x3f3f3f3f;
      int n,x,y,a[N],b[N],c[N];
      int len;
      int main(){
      	scanf("%d",&n);
      	for(int i=1;i<=n;i++){
      		scanf("%d%d",&x,&y);
      		a[n-i]=x;
      		b[n-i]=y;
      	}
      	x=0;
      	for(int i=0;i<n;i++){
      		c[i]=a[i]+b[i]+x;
      		x=c[i]/10;
      		c[i]%=10;
      	}
      	len=n-1;
      	if(x){
      		c[++len]=x;
      	}
      	for(int i=len;i>=0;i--){
      		printf("%d",c[i]);
      	}
      return 0;
      }
      
      
      • 1

      信息

      ID
      1675
      时间
      1000ms
      内存
      256MiB
      难度
      6
      标签
      递交数
      142
      已通过
      45
      上传者