-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCF_Dating.cpp
More file actions
executable file
·78 lines (78 loc) · 1.02 KB
/
CF_Dating.cpp
File metadata and controls
executable file
·78 lines (78 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include<cstdio>
#include<cstdlib>
#include<cstring>
int n;
const int maxn=200005;
char s[maxn];
int l;
char ans[maxn*2];
int tot;
int sum(int s)
{
int re=0;
while(s)
{
re+=s%10;
s/=10;
}
return re;
}
bool check(int s)
{
return sum(sum(s))<10;
}
int tmp[25],t;
void printall(int x)
{
t=0;
while(x)
{
tmp[t++]=x%10;
x/=10;
}
printf("%d",tmp[t-1]);
for (int i=t-2;i>=0;--i) printf("+%d",tmp[i]);
puts("");
}
int main()
{
srand(233333);
scanf("%d",&n);
scanf("%s",s);
l = strlen(s);
while(1)
{
int s2=0;
tot = 0;
ans[0]=s[0];
s2=s[0]-'0';
++tot;
for (int i=tot;i<l;)
{
ans[tot++]='+';
if (i==l-1 || rand()%2)
{
ans[tot++] = s[i];
s2+=s[i]-'0';
++i;
}
else
{
ans[tot++] = s[i];
ans[tot++] = s[i+1];
s2+=(s[i]-'0')*10;
s2+=s[i+1]-'0';
i+=2;
}
}
if (check(s2))
{
ans[tot]=0;
printf("%s\n", ans);
printall(s2);
printall(sum(s2));
break;
}
}
return 0;
}