1338 条题解
-
-1
yll2017 LV 4 @ 2017-07-13 15:52:01
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b;
c=a+b;
cout<<c<<endl;
return 0;
} -
-1@ 2017-07-12 15:01:01
很简单
#include <cstdio> #include <iostream> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b<<endl; return 0; } -
-1@ 2017-07-09 11:46:18
#include<iostream>
#include<cstdio>
#include<ctime>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
int A,B;
cin>>A>>B;
cout<<A+B;
return 0;
} -
-1@ 2017-06-22 20:25:44
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
} -
-1@ 2017-06-22 20:25:12
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
} -
-1@ 2017-05-29 19:06:27
#include<iostream> using namespace std; int main() { int a,b; cin>>a>>b; cout<<a+b; return 0; } -
-1@ 2017-03-05 12:02:25
main函数自递归和位运算
#include<bits/stdc++.h> int main(int a,int b,int k) { if (k) scanf("%d%d",&a,&b); printf("%d",b==0?a:main(a^b,(a&b)<<1,0)); exit(0); } -
-1@ 2017-01-31 10:32:00
#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
cout << a + b << endl;
return 0;
} -
-1@ 2017-01-25 11:23:57
走一波面向对象的A+B。
<pre>
#include <bits/stdc++.h>using namespace std;
class Something
{
friend istream & operator>>(istream & is, Something & as);
friend ostream & operator<<(ostream & os, Something & as);
public:
int a, b;
int sum(int x, int y);
Something & operator+(int z);
Something & operator+(Something b);};
istream & operator>>(istream & is, Something & as)
{
is >> as.a;
return is;
}ostream & operator<<(ostream & os, Something & as)
{
os << as.a;
return os;
}int Something::sum(int x, int y)
{
return x + y;
}Something & Something::operator+(int z)
{
a += z;
return *this;
}Something & Something::operator+(Something b)
{
a += b.a;
return *this;
}int main(int argc, char const *argv[])
{
Something sd, st;
cin >> sd >> st;
cout << sd + st;
return 0;
}
</pre> -
-1@ 2017-01-22 14:12:30
#include<iostream> //基础头文件
using namespace std; //自定义函数
int main() //输入命令
{
int a,b=0,n=2; //1.定义a,用来输入两个数。 2.定义b,用来计数输入的两个数。 3.定义n,用来循环2次。
for(int i=1;i<=n;i++) //开始循环,循环次数n,n=2
{
cin>>a; //输入a;经循环共两次
b+=a; //计数,为了方便统计,输出时直接把b输出。
} //循环结束。
cout<<b; //输出循环后的结果。
return 0;
} -
-1@ 2017-01-18 17:51:33
#include <stdio.h> int main() { int a, b; scanf("%d%d", &a, &b); printf("%d\n", a + b); return 0; } -
-1@ 2017-01-07 11:36:37
#include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a + b << endl; return 0; } -
-1@ 2016-12-26 23:24:08
#include <stdio.h>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
printf("%d\n", a + b);
return 0;
} -
-1@ 2016-12-14 13:15:12
#include<cstdio> #include<cstring> #include<iostream> using namespace std; char a1[10000],b1[10000];int a[10000],b[10000],c[10000],x=0,lena,lenb,lenc=1,i; int main() { scanf("%s",a1);scanf("%s",b1);lena=strlen(a1);lenb=strlen(b1); for(i=0;i<=lena-1;i++) a[lena-i]=a1[i]-'0'; for(i=0;i<=lenb-1;i++) b[lenb-i]=b1[i]-'0'; while(lenc<=lena||lenc<=lenb) { c[lenc]=a[lenc]+b[lenc]+x; x=c[lenc]/10; c[lenc]%=10; lenc++; } if(0==(c[lenc]=x)) lenc--; for(i=lenc;i>=1;i--) cout<<c[i];return 0; } -
-1@ 2016-12-14 13:14:54
好长时间才做出来
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char a1[10000],b1[10000];int a[10000],b[10000],c[10000],x=0,lena,lenb,lenc=1,i;
int main()
{
scanf("%s",a1);scanf("%s",b1);lena=strlen(a1);lenb=strlen(b1);
for(i=0;i<=lena-1;i++) a[lena-i]=a1[i]-'0';
for(i=0;i<=lenb-1;i++) b[lenb-i]=b1[i]-'0';
while(lenc<=lena||lenc<=lenb)
{
c[lenc]=a[lenc]+b[lenc]+x;
x=c[lenc]/10;
c[lenc]%=10;
lenc++;
}
if(0==(c[lenc]=x)) lenc--;
for(i=lenc;i>=1;i--) cout<<c[i];return 0;
} -
-1@ 2016-12-14 11:58:17
高精度的代码,其实是比较暴力的高精,但是因为它小于等于2^15-1,所以没什么关系。
我是通用性的高精度代码,所以数组开了10000.接下来就是——代码!
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char a1[10000],b1[10000];int a[10000],b[10000],c[10000],x=0,lena,lenb,lenc=1,i;
int main()
{
scanf("%s",a1);scanf("%s",b1);lena=strlen(a1);lenb=strlen(b1);
for(i=0;i<=lena-1;i++) a[lena-i]=a1[i]-'0';
for(i=0;i<=lenb-1;i++) b[lenb-i]=b1[i]-'0';
while(lenc<=lena||lenc<=lenb)
{
c[lenc]=a[lenc]+b[lenc]+x;
x=c[lenc]/10;
c[lenc]%=10;
lenc++;
}
if(0==(c[lenc]=x)) lenc--;
for(i=lenc;i>=1;i--) cout<<c[i];return 0;
}
祝大家刷题快乐,从这里开始。 -
-1@ 2016-12-11 18:55:20
以下题解不必去理解,为搜集到的大牛解法,当然,也有自己写的
-
-1@ 2016-12-11 18:53:55
你们怎么能水过这题呢?
这么好的一道网络流的题,应当用高标预流推进
[/color][codec ]#include<bits/stdc++.h>
using namespace std;
#define set(x) Set(x)
#define REP(i,j,k) for (int i=(j),_end_=(k);i<=_end_;++i)
#define DREP(i,j,k) for (int i=(j),_start_=(k);i>=_start_;--i)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()-1))
#define ALL(x) ((x).begin()+1),(x).end()
template<typename T> inline bool chkmin(T &a,const T &b){ return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a,const T &b){ return a < b ? a = b, 1 : 0; }
typedef long long LL;
typedef pair<int,int> node;
const int dmax=1010,oo=0x3f3f3f3f;
int n,m;
int a[dmax][dmax] , ans;
int d[dmax],e[dmax];
priority_queue <node> q;
inline bool operator >(node a,node b){ return a.y>b.y; }
bool p[dmax];
void Set(int x){ p[x]=1; }
void unset(int x){ p[x]=0; }
bool check(int x){ return x!=1 && x!=n && !p[x] && e[x]>0; }
void preflow(){
e[1]=oo;
d[1]=n-1;
q.push(mp(1,n-1));
set(1);
while (!q.empty()){
bool flag=1;
int k=q.top().x;
q.pop(),unset(k);
DREP(i,n,1)
if ((d[k]==d[i]+1 || k==1) && a[k][i]>0){
flag=0;
int t=min(a[k][i],e[k]);
e[k]-=t;
a[k][i]-=t;
e[i]+=t;
a[i][k]+=t;
if (check(i)){
q.push(mp(i,d[i]));
set(i);
}
if (e[k]==0) break;
}
if (flag){
d[k]=oo;
REP(i,1,n)
if (a[k][i]>0)
chkmin(d[k],d[i]+1);
}
if (check(k)){
q.push(mp(k,d[k]));
set(k);
}
}
ans=e[n];
}
int main(){
n = 2, m = 2;
int x, y;
scanf("%d%d", &x, &y);
a[1][2] += x + y;
preflow();
printf("%d\n",ans);
return 0;
}
[/codec ] -
-1@ 2016-12-11 18:53:19
program problem;
var
en,et,ec,eu,ep,ex:Array[0..250000] of longint;
dis:array[0..1000] of longint;
v:array[0..1000] of boolean;
i,j,k,n,m,w,cost,l:longint;
a,b,ans,left,right:longint;
function min(a,b:longint):longint;
begin
if a<b then min:=a else min:=b
end;
procedure addedge(s,t,c,u,k:longint);
begin
inc(l);
en[l]:=en[s];
en[s]:=l;
et[l]:=t;
ec[l]:=c;
eu[l]:=u;
ep[l]:=l+k;
end;
procedure build(s,t,u,c:longint);
begin
addedge(s,t,c,u,1);
addedge(t,s,-c,0,-1);
end;
function aug(no,m:longint):longint;
var
i,d:longint;
begin
if no=n then
begin
inc(cost,m*dis[1]);
exit;
end;
v[no]:=true;
i:=ex[no];
while i<>0 do
begin
if (eu[i]>0)and not v[et[i]] and(dis[et[i]]+ec[i]=dis[no]) then
begin
d:=aug(et[i],min(m,eu[i]));
if d>0 then
begin
dec(eu[i],d);
inc(eu[ep[i]],d);
ex[no]:=i;
exit(d);
end;
end;
i:=en[i];
end;
ex[no]:=i;
exit(0);
end;
function modlabel:boolean;
var
d,i,j:longint;
begin
d:=maxlongint;
for i:=1 to n do
if v[i] then
begin
j:=en[i];
while j<>0 do
begin
if (eu[j]>0)and not v[et[j]] and(ec[j]-dis[i]+dis[et[j]]<d) then
d:=ec[j]-dis[i]+dis[et[j]];
j:=en[j]
end;
end;
if d=maxlongint then exit(true);
for i:=1 to n do
if v[i] then
begin
v[i]:=false;
inc(dis[i],d);
end;
exit(false);
end;
function work:longint;
var i:longint;
begin
cost:=0;
repeat
for i:=1 to n do ex[i]:=en[i];
while aug(1,maxlongint)>0 do
fillchar(v,sizeof(v),0);
until modlabel;
work:=cost;
end;
function solve(x,d:longint):longint;
var i,k,t,p,last,cost,lk:longint;
begin
fillchar(en,sizeof(en),0);
fillchar(dis,sizeof(dis),0);
k:=0; n:=2; t:=x; p:=0;
while x<>0 do
begin
k:=k+x mod 10;
x:=x div 10;
inc(p);
end;
n:=1; x:=t; l:=k+p+1; last:=1; cost:=1; lk:=0;
while x<>0 do
begin
k:=x mod 10;
for i:=1 to k do
begin
inc(n);
build(last,n,1,-cost);
build(n,last+k+1,1,0);
end;
cost:=cost*10;
inc(n);
if last<>1 then
begin
if lk<k then
build(1,last,k-lk,0);
if k<lk then
build(last,n,lk-k,0);
end;
last:=n; x:=x div 10;
if lk<k then lk:=k;
end;
build(1,n,1,d);
solve:=-work;
end;
begin
readln(a,b);
left:=1; right:=1000000000;
while right-left>15000 do
begin
ans:=(left+right)shr 1;
if solve(ans,b)>a then
right:=ans
else left:=ans;
end;
for i:=left to right do
if solve(i,b)=a then
begin
writeln(i);
halt;
end;
end. -
-1@ 2016-12-11 18:52:57
这道题实际上是一道最短路的模型题。我们只需要构造一个有三个顶点的无向图,1和2之间有一条边权为a的边,2和3之间有一条边权为b的边,而1和3之间有一条边权为maxlongint的边,那么答案就是1到3的最短路
信息
- ID
- 1000
- 难度
- 9
- 分类
- (无)
- 标签
- (无)
- 递交数
- 75671
- 已通过
- 28884
- 通过率
- 38%
- 被复制
- 279