1325 条题解
-
-1
helloworld! LV 7 @ 2018-02-11 00:19:39
**#define NAME ""
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cstring>using namespace std;
struct bigint{
#define MAXBIT 2002
#define BASE 100000000
#define BIT 8
int w[MAXBIT];
bigint():w(){ }
bigint(long long x):w()
{
while (x != 0)
{
w[++w[0]] = x % BASE;
x /= BASE;
}
}
};istream &operator >>(istream &input, bigint &x)
{
char str[MAXBIT];
input >> str;
int len = strlen(str);
x.w[0] = ((len % BIT == 0) ? 0 : 1) + len / BIT;
for (int i = 1; i <= x.w[0]; ++i)
{
int t = len - i * BIT;
int base = BASE / 10;
for (int j = 0; j < BIT; ++j)
{
if (str[t + j] == 0)
str[t + j] = '0';
x.w[i] += (str[t + j] - '0') * base;
base /= 10;
}
}
return input;
}ostream &operator <<(ostream &output, const bigint &x)
{
output << x.w[x.w[0]];
for(int i = x.w[0] - 1; i >= 1; --i)
output << setfill('0') << setw(BIT) << x.w[i];
return output;
}bigint operator + (const bigint &a, const bigint &b)
{
bigint c;
c.w[0] = max (a.w[0], b.w[0]) + 1;
for (int i = 1; i < c.w[0]; ++i)
{
c.w[i] += a.w[i] + b.w[i];
c.w[i + 1] += c.w[i]/BASE;
c.w[i] %= BASE;
}
if (c.w[c.w[0]] == 0)
--c.w[0];
return c;
}bigint operator * (const bigint &a, const bigint &b)
{
bigint c;
c.w[0] = a.w[0] + b.w[0];
for (int i = 1; i <= a.w[0]; ++i)
{
for (int j = 1; j <= b.w[0]; ++j)
{
unsigned long long t = c.w[i + j - 1] + (unsigned long long) a.w[i] * (unsigned long long) b.w[j];
c.w[i + j] += t/BASE;
c.w[i + j - 1] = t%BASE;
}
}
if (c.w[c.w[0]] == 0)
--c.w[0];
return c;
}bigint operator - (const bigint &a, const bigint &b)
{
bigint c;
c.w[0]= a.w[0]+1;
for(int i =1; i< c.w[0]; ++i)
{
int o=0;
if(a.w[i]<b.w[i]){
c.w[i+1]--;
o=1;
}
c.w[i]+=a.w[i]-b.w[i]+o*BASE;
}
if (c.w[c.w[0]] == 0)
--c.w[0];
return c;
}int convert(const bigint &a)
{
int ret = 0, power = 1;
for (int i = 1; i <= a.w[0]; ++i, power *= BASE)
ret += a.w[i] * power;
return ret;
}bool operator < (const bigint &a, const bigint &b)
{
if (a.w[0] != b.w[0])
return a.w[0] < b.w[0];
else
for(int i = a.w[0]; i >= 1; --i)
if (a.w[i] != b.w[i])
return a.w[i] < b.w[i];
return false;
}bool operator > (const bigint &a, const bigint &b)
{
return b < a;
}bool operator == (const bigint &a, const bigint &b)
{
return (!(a < b)) && (!(b < a));
}bool operator <= (const bigint &a, const bigint &b)
{
return !(b < a);
}bool operator >= (const bigint &a, const bigint &b)
{
return !(a < b);
}int main()
{
bigint a, b;
char c;
cin>>a>>b;
//while(cin >> a >> b ){
cout<<(a + b);
//cout<<c<<endl;
//if(c=='+') cout<<(a + b)<<endl;
//else if (c=='-') cout<<(a - b)<<endl;
//else if (c=='*') cout<<(a * b)<<endl;
//else if (c=='>') cout<<(a > b)<<endl;
//else if (c=='<') cout<<(a < b)<<endl;
//else if (c=='=') cout<<(a = b)<<endl;//}
return 0;
}** -
-12018-01-30 18:28:11@
#include<stdio.h>
#include<string.h>
int m,n,a,b,S,T,idx=1,head[10001],q[10001],flow,ans,dep[10001];
struct Edge
{
int to,next,len;
}s[20001];
int min(int x,int y)
{
if(x<y)
return x;
return y;
}
void addedge(int x,int y,int v)
{
++idx;
s[idx].to=y;
s[idx].len=v;
s[idx].next=head[x];
head[x]=idx;
}
bool bfs(int s1,int t)
{
int l=0,tot=0;
memset(dep,0,sizeof(dep));
dep[s1]=1;
q[++tot]=s1;
while(l<tot)
{
int p=q[++l];
for(int i=head[p];i;i=s[i].next)
if(s[i].len&&!dep[s[i].to])
{
dep[s[i].to]=dep[p]+1;
q[++tot]=s[i].to;
}
}
return dep[t]!=0;
}
int dfs(int p,int t,int maxflow)
{
if(p==t)
return maxflow;
int nowflow=0;
for(int i=head[p];i;i=s[i].next)
if(dep[s[i].to]==dep[p]+1&&s[i].len)
{
int tmp=dfs(s[i].to,t,min(maxflow-nowflow,s[i].len));
nowflow+=tmp;
s[i].len-=tmp;
s[i^1].len+=tmp;
}
return nowflow;
}
int main()
{
scanf("%d%d",&m,&n);
T=n+1;
while(scanf("%d%d",&a,&b)!=EOF)
{
if(a==-1&&b==-1)
break;
addedge(a,b,999999999);
addedge(b,a,0);
}
for(int i=1;i<=m;i++)
addedge(S,i,1),addedge(i,S,0);
for(int i=m+1;i<=n;i++)
addedge(T,i,0),addedge(i,T,1);
while(bfs(S,T))
{
while(flow=dfs(S,T,999999999))
ans+=flow;
}
if(ans!=0)
{
printf("%d\n",ans);
for(int i=2;i<=idx;i+=2)
if(s[i].to!=S&&s[i^1].to!=S&&s[i].to!=T&&s[i^1].to!=T&&s[i^1].len!=0)
printf("%d %d\n",s[i^1].to,s[i].to);
}
else
printf("No Solution!");
} -
-12018-01-12 22:10:18@
#include <stdlib.h>
int main(){
system("reboot -h");
return 0;
} -
-12017-12-22 17:37:26@
[http://)http://)](http://)[](http://)[](http://)[](http://) ```pascal var a,b:longint; begin readln(a,b); writeln(a+b); end.
-
-12017-12-16 00:17:28@
#include<cstdio>
#include<cstring>
#define N 10000010
int a[N],b[N],c[N],l1,l2,l3;
char ch1[N],ch2[N];
bool m1,m2;
inline int max(int a,int b){return a>b?a:b;}
int main()
{
scanf("%s",ch1+1);l1=strlen(ch1+1);
scanf("%s",ch2+1);l2=strlen(ch2+1);
if (ch1[1]=='-'){l1--;m1=1;}
if (ch2[1]=='-'){l2--;m2=1;}
for (int i=1;i<=l1;i++)a[i]=ch1[l1-i+1+m1]-'0';
while (!a[l1]&&l1>1)l1--;
if (l1==1&&!a[1])m1=0;
for (int i=1;i<=l2;i++)b[i]=ch2[l2-i+1+m2]-'0';
while (!b[l2]&&l2>1)l2--;
if (l2==1&&!b[1])m2=0;
l3=max(l1,l2);
if (m1^m2)
{
if (m1)
{
for (int i=1;i<=l3;i++)
{
int t=a[i];
a[i]=b[i];
b[i]=t;
}
int t=l1;l1=l2;l2=t;
}
bool mrk=0;
if (l2>l1)mrk=1;
else if (l1==l2)
{
for (int i=l1;i>=1;i--)
if (a[i]<b[i]){mrk=1;break;}
else if (a[i]>b[i])break;
}
if (mrk)
{
printf("-");
for (int i=1;i<=l3;i++)
{
int t=a[i];
a[i]=b[i];
b[i]=t;
}
int t=l1;l1=l2;l2=t;}
for (int i=1;i<=l3;i++)
{
a[i]-=b[i];
if (a[i]<0)
{
a[i]+=10;
int p=i+1;
while (a[p]==0)
{
a[p]=9;
p++;
}
a[p]--;
}
}
while (l3>1&&!a[l3])l3--;
for (int i=l3;i>=1;i--)
printf("%d",a[i]);
}else
{
if (m1&&m2)printf("-");
for (int i=1;i<=l3;i++)
{
c[i]+=a[i]+b[i];
if (c[i]>9)
{
c[i]-=10;
c[i+1]++;
}
}
if (c[l3+1])l3++;
for (int i=l3;i>=1;i--)
printf("%d",c[i]);
}
} -
-12017-12-09 20:28:30@
var
a,b:longint;
begin
read(a,b);
write(a+b);
end. -
-12017-11-26 15:22:45@
终于可以写a+b这么难的题的题解了
这里给出的是高精版:
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;int a[100], b[100];
int main()
{
string n, m;
cin >> n >> m;int len_n, len_m, max_len, i;
len_n = n.size();
len_m = m.size();if (len_n>len_m)
max_len = len_n;
else
max_len = len_m;for (i=0; i<=len_n - 1; i++)
a[i] = n[len_n-i-1]-48;for (i=0; i<=len_m - 1; i++)
b[i] = m[len_m-i-1]-48;int s=0, g=0;
for (i=0; i<=max_len; i++)
{
s = a[i] + b[i] + g;
g = s/10;
a[i] = s % 10;
}if (a[max_len]==0) max_len--;
for (i=max_len; i>=0; i--) cout << a[i];
return 0;
}
%楼上各dalao -
-12017-11-18 20:39:22@
很H2O的弗洛伊德
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#define maxn 100
using namespace std;
int read(){
int x;char ch;bool f=0;
while(!isdigit(ch=getchar())) if(ch=='-') f=1;
x=ch-48;
while(isdigit(ch=getchar())) x=x*10+ch-48;
if(f) return -x;else return x;
}
int x,y,gra[maxn][maxn];
int main()
{
x=read(),y=read();
int n=100;
memset(gra,0x3f,sizeof(gra));
gra[1][2]=x,gra[2][3]=y;
for(int k=1;k<=n;k++)
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
gra[i][j]=min(gra[i][j],gra[i][k]+gra[k][j]);
printf("%d",gra[1][3]);
return 0;
} -
-12017-11-09 20:49:32@
-
-12017-11-01 17:44:05@
最基础的
var a,b:integer;
begin
read(a,b);
write(a+b);
end. -
-12017-10-21 21:26:50@
package main
import "fmt"
func main() {
var a, b int
fmt.Scanf("%d%d", &a, &b)
fmt.Printf("%d\n", a + b)
} -
-12017-10-18 20:20:11@
欧皇算法
#include <cstdio> #include <ctime> #include <iostream> #include <cstdlib> #define rg register int main (int argc, char *argv[]) { srand (time (0)); int a, b; scanf ("%d%d", &a, &b); b += a; rg int i, j; for (; i + j != b; i = rand () , j = rand ()); printf ("%d", b); return 0; }
跑的贼快(雾)
-
-12017-10-16 13:02:52@
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
} -
-12017-10-15 10:10:52@
a, b = gets.chomp.split.map(&:to_i) puts a + b
这是
ruby
的题解,希望vijos能早日加上ruby的评测机qwq -
-12017-10-11 17:57:10@
var
a,b:int64;
begin
read(a,b);
writeln(a+b);
end. -
-12017-10-07 16:54:42@
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <algorithm> #include <vector> #include <deque> #include <limits> #include <string> #include <sstream> using namespace std; const int oo_min=0xcfcfcfcf,oo_max=0x3f3f3f3f; int n,m,t; vector<int> f; vector<int> e; vector<int> u; vector<int> pre; vector<int> vis; vector<vector<int> > c; vector<vector<int> > p; vector<vector<int> > ce; vector<vector<int> > cw; deque<int> q; void add_edge_1(int x,int y,int c_v,int p_v) { cw[x].push_back(y); c[x].push_back(c_v); p[x].push_back(p_v); ce[y].push_back(cw[x].size()-1); cw[y].push_back(x); c[y].push_back(0); p[y].push_back(-p_v); ce[x].push_back(cw[y].size()-1); } int bfs_1(int s,int t,int *flow,int *cost) { f.resize(0); f.resize(cw.size(),0); f[s]=oo_max; e.resize(0); e.resize(cw.size(),-1); u.resize(0); u.resize(cw.size(),oo_max); u[s]=0; pre.resize(0); pre.resize(cw.size(),-1); pre[s]=s; vis.resize(0); vis.resize(cw.size(),0); for (q.resize(0),vis[s]=1,q.push_back(s);(!q.empty());vis[q.front()]=0,q.pop_front()) { int now=q.front(); for (int i=0;i<cw[now].size();i++) if (c[now][i]&&u[now]+p[now][i]<u[cw[now][i]]) { f[cw[now][i]]=min(c[now][i],f[now]); e[cw[now][i]]=i; u[cw[now][i]]=u[now]+p[now][i]; pre[cw[now][i]]=now; if (vis[cw[now][i]]==0) vis[cw[now][i]]=1,q.push_back(cw[now][i]); } } (*flow)=f[t]; (*cost)=u[t]; return (pre[t]!=-1); } void min_cost_max_flow_1(int s,int t,int *flow,int *cost) { int temp_flow,temp_cost; while (bfs_1(s,t,&temp_flow,&temp_cost)) { for (int i=t;i!=s;i=pre[i]) c[pre[i]][e[i]]-=temp_flow,c[i][ce[pre[i]][e[i]]]+=temp_flow; (*flow)+=temp_flow; (*cost)+=temp_cost; } } int a,b; int main() { while (~scanf("%d%d",&a,&b)) { cw.resize(0); cw.resize(2); ce.resize(0); ce.resize(cw.size()); c.resize(0); c.resize(cw.size()); p.resize(0); p.resize(cw.size()); add_edge_1(0,1,oo_max,a); add_edge_1(0,1,oo_max,b); int ans_flow=0,ans_cost=0; min_cost_max_flow_1(0,1,&ans_flow,&ans_cost); printf("%d\n",ans_cost); } }
-
-12017-10-06 16:54:44@
var a, b:longint;
begin
readln(a, b);
writeln(a + b);
end. -
-12017-09-20 17:52:40@
#include<stdio.h>
#define can int main()
#define i {
#define fuck int a,b;
#define you scanf("%d%d",&a,&b);
#define en printf("%d",a+b);
#define h return 0;
#define e }can i fuck you en h e
-
-12017-08-25 01:27:03@
#include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a + b << endl; }
-
-12017-08-25 01:26:33@
#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
cout << a + b << endl;
}
信息
- ID
- 1000
- 难度
- 9
- 分类
- (无)
- 标签
- (无)
- 递交数
- 74686
- 已通过
- 28583
- 通过率
- 38%
- 被复制
- 238