Editorial for A cộng B
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này
Code mẫu của flashmt
import sys a, b = sys.stdin.readline().split() print(int(a) + int(b))
Code mẫu của happyboy99x
import java.util.Scanner; public class Main { public static void main( String[] argv ) { Scanner scan = new Scanner(System.in); System.out.println(scan.nextInt() + scan.nextInt()); scan.close(); } }
Code mẫu của ladpro98
const fi=''; fo=''; var f:text; a,b,c:longint; procedure docf; begin assign(f,fi); reset(f); read(f,a,b); close(f); end; procedure ghif; begin assign(f,fo); rewrite(f); c:=a+b; write(f,c); close(f); end; begin docf; ghif; end.
Code mẫu của RR
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; cout << a+b; }
Code mẫu của hieult
#include<cstdio> #include<cmath> #include<math.h> #include<cstring> #include<cstdlib> #include<cassert> #include<ctime> #include<algorithm> #include<iterator> #include<iostream> #include<cctype> #include<string> #include<vector> #include<map> #include<set> #include<queue> #include<list> #define ep 0.00001 #define maxn 1030 #define oo 2000000001 #define modunlo 111539786 #define TR(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++) #define fi first #define se second //#define g 9.81 double const PI=4*atan(1.0); using namespace std; typedef pair<int, int> II; typedef vector<int> VI; typedef vector<II> VII; typedef vector<VI> VVI; typedef vector<VII> VVII; double f[105][105][205]; int main(){ // freopen("input.in","r",stdin); // freopen("output.out","w",stdout); int a,b; scanf("%d %d",&a,&b); printf("%d\n",a+b); }
Code mẫu của ll931110
Program POST; Const input = ''; output = ''; Var a,b: longint; f: text; Begin Assign(f, input); Reset(f); Readln(a, b); Close(f); Assign(f, output); Rewrite(f); Writeln(a + b); Close(f); End.
Code mẫu của skyvn97
#include<stdio.h> #include<string.h> #include<algorithm> #define MAX 3111 using namespace std; struct bignum { int nd; int sb; int d[MAX]; bignum() { nd=0; } bignum(int x) { if (x==0) { nd=1; sb=1; d[1]=0; } if (x>0) { nd=0; sb=1; while (x>0) { nd++; d[nd]=x%10; x=x/10; } } if (x<0) { nd=0; sb=-1; x=-x; while (x>0) { nd++; d[nd]=x%10; x=x/10; } } } bignum(const bignum &x) { nd=x.nd; sb=x.sb; int i; for (i=1;i<=nd;i=i+1) d[i]=x.d[i]; } void input(void) { char s[MAX]; scanf("%s",s); sb=1; nd=0; int i; for (i=strlen(s)-1;i>=0;i=i-1) { nd++; d[nd]=s[i]-48; } } void print(void) { if (sb<0) printf("-"); int i; for (i=nd;i>=1;i=i-1) printf("%d",d[i]); } bignum abs() { bignum r=bignum(*this); r.sb=1; return (r); } int cmp(const bignum&x) { if (sb>x.sb) return (1); if (sb<x.sb) return (-1); if (nd>x.nd) return (sb); if (nd<x.nd) return (-sb); int i; for (i=nd;i>=1;i=i-1) { if (d[i]>x.d[i]) return (sb); if (d[i]<x.d[i]) return (-sb); } return (0); } bignum operator + (const bignum &x) // only compatible for non-negative integer { int n=max(nd,x.nd); int i,s,c; bignum res (*this); res=bignum(); res.sb=1;; s=0;c=0; for (i=nd+1;i<=n;i=i+1) d[i]=0; //for (i=x.nd+1;i<=n;i=i+1) x.d[i]=0; for (i=1;i<=n;i=i+1) { s=d[i]+x.d[i]+c; if (s>9) c=1; else c=0; res.nd++; res.d[res.nd]=s%10; } if (c>0) { res.nd++; res.d[res.nd]=1; } return (res); } bignum operator - (const bignum &x) // only compatible for non-negative integer { int tmp=cmp(x); if (tmp>0) { bignum res; res=bignum(); res.sb=1; int i,s,c; //for (i=x.nd+1;i<=nd;i=i+1) x.d[i]=0; s=0; c=0; for (i=1;i<=nd;i=i+1) { s=d[i]-x.d[i]-c; if (s<0) { s=s+10; c=1; } else c=0; res.nd++; res.d[res.nd]=s%10; } while (res.d[res.nd]==0) res.nd--; return (res); } if (tmp==0) return (bignum(0)); if (tmp<0) { bignum res; res=bignum(); int i,s,c; res.sb=-1; s=0;c=0; for (i=nd+1;i<=x.nd;i=i+1) d[i]=0; for (i=1;i<=x.nd;i=i+1) { s=x.d[i]-d[i]-c; if (s<0) { s=s+10; c=1; } else c=0; res.nd++; res.d[res.nd]=s%10; } while (res.d[res.nd]==0) res.nd--; return (res); } } bignum operator * (const bignum &x) //compatible for all numbers { if ((nd==1) && (d[1]==0)) return (bignum(0)); if ((x.nd==1) && (x.d[1]==0)) return (bignum(0)); bignum res; res=bignum(); res.sb=sb*x.sb; int i,j,s,c; for (i=1;i<=x.nd;i=i+1) { bignum tmp=bignum(); for (j=1;j<i;j=j+1) { tmp.nd++; tmp.d[tmp.nd]=0; } s=0;c=0; for (j=1;j<=nd;j=j+1) { s=d[j]*x.d[i]+c; c=s/10; tmp.nd++; tmp.d[tmp.nd]=s%10; } while (c>0) { tmp.nd++; tmp.d[tmp.nd]=c%10; c=c/10; } res=res+tmp; } return (res); } }; bignum a,b,c; int main(void) { a.input(); b.input(); c=a+b; c.print(); return 0; }
Code mẫu của khuc_tuan
{$mode ObjFpc} uses SysUtils; type TClassA = class function tinh(a,b:integer) : integer; virtual; abstract; end; TClassB = class(TClassA) function tinh(a,b:integer) : integer; override; end; TClassC = class(TClassA) function tinh(a,b:integer) : integer; override; end; var a : TClassA; x, y : integer; ar : array[1..10] of integer; na : integer; function TClassB.tinh(a,b:integer) : integer; begin result := a + b; end; function TClassC.tinh(a,b:integer) : integer; begin result := a * b; end; begin a := TClassB.Create; ReadLn(x,y); WriteLn(a.tinh(x,y)); end.
Comments
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.