# A + B

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 21551    Accepted Submission(s): 12895

Problem Description

Input

Output

Sample Input

 
one + two = three four + five six = zero seven + eight nine = zero + zero =

Sample Output

 

把英语单词分别讨论处理，注意输入格式。

#include<bits/stdc++.h>
using namespace std;
const int maxn=30;
string ch;
char c1[maxn],c2[maxn],c3[maxn],c4[maxn];
int ok(char c1[])
{
int a=0;
if(c1[0]=='o')
a=1;
else if(c1[0]=='e')
a=8;
else if(c1[0]=='n')
a=9;
else if(c1[0]=='z')
a=0;
else if(c1[0]=='t')
{
if(c1[1]=='w')
a=2;
else
a=3;
}
else if(c1[0]=='f')
{
if(c1[1]=='o')
a=4;
else
a=5;
}
else if(c1[0]=='s')
{
if(c1[1]=='i')
a=6;
else
a=7;
}
return a;
}
int main()
{
while(true)
{
int len=ch.size();
int i=0;
int j1=0,j2=0,j3=0,j4=0;
int f1=0,f11=0,f21=0;
for(int i=0; i<len; i++)
{
//cout<<ch[i]<<endl;
if(ch[i]=='=')break;
if(ch[i]=='+')
{
f1=1;
++i;
continue;
}
if(ch[i]==' '&&!f1)
{
f11=1;
continue;
}
if(ch[i]==' '&&f1)
{
f21=1;
continue;
}
if(f1)//+后面
{
if(!f21)
{
c3[j3++]=ch[i];
}
else
{
c4[j4++]=ch[i];
}
}
else //+前面
{
if(!f11)
{
c1[j1++]=ch[i];
//cout<<c1[j1]<<endl;
}
else
{
c2[j2++]=ch[i];
}
}
}
int a=0,b=0,c=0,d=0;
int s1=0,s2=0;
if(j1&&j2)
{
a=ok(c1);
b=ok(c2);
s1=a*10+b;
}
else
{
a=ok(c1);
s1=a;
}
if(j3&&j4)
{
c=ok(c3);
d=ok(c4);
s2=c*10+d;
}
else
{
c=ok(c3);
s2=c;
}
if(a==0&&c==0)
return 0;
//cout<<s1<<" "<<s2<<endl;
cout<<s1+s2<<endl;
}
}

# 最大连续子序列

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 44756    Accepted Submission(s): 20452

Problem Description

Nj }，其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个，

Input

Output

Sample Input


6 -2 11 -4 13 -5 -2 10 -10 1 2 3 4 -5 -23 3 7 -21 6 5 -8 3 2 5 0 1 10 3 -1 -5 -2 3 -1 0 -2 0

Sample Output


20 11 13 10 1 4 10 3 5 10 10 10 0 -1 -2 0 0 0
Hint
Hint

Huge input, scanf is recommended.

#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 10000 + 66;
int a[maxn];
int main()
{
int k;
while (scanf("%d",&k)&&k)
{
for (int i = 1; i <= k; i++)
{
scanf("%d", &a[i]);
}
int s = 0;
int maxx = -99999999;
int l1 = 0, l2 = 0;
int ansa = 0, ansb = 0;
for (int i = 1; i <= k; i++)
{
if (s < 0)
{
s = a[i];
l1 = a[i];
l2 = a[i];
}
else
{
s += a[i];
l2 = a[i];
}

if (s > maxx)
{
maxx = s;
ansa = l1;
ansb = l2;
}
}
if(maxx>=0)
printf("%d %d %d\n", maxx,ansa,ansb);
else
{
printf("%d %d %d\n", 0, a[1], a[k]);
}
}
//getchar();
return 0;
}

# 畅通工程

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 85855    Accepted Submission(s): 45590

Problem Description

Input

3 3
1 2
1 2
2 1

Output

Sample Input


4 2 1 3 4 3 3 3 1 2 1 3 2 3 5 2 1 2 3 5 999 0 0

Sample Output


1 0 2 998
Hint
Hint
Huge input, scanf is recommended.

Source

Recommend
JGShining

#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 10000 + 66;
int fa[maxn];
int find(int x)
{
return fa[x] == x ? x : fa[x] = find(fa[x]);
}
void init(int x, int y)
{
int fx = find(x);
int fy = find(y);
if (fx != fy)
{
fa[fx] = fy;
}
}
int main()
{
int n,m;
while (scanf("%d",&n)&&n)
{
for (int i = 1; i <= n; i++)fa[i] = i;
scanf("%d", &m);
while (m--)
{
int u, v;
scanf("%d %d", &u, &v);
init(u, v);
}
for (int i = 1; i <= n; i++)
{
find(i);
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
if (i == fa[i])ans++;
}
printf("%d\n", ans - 1);
}
}

# 开门人和关门人

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 22975    Accepted Submission(s): 11504

Problem Description

Input

Output

Sample Input


3 1 ME3021112225321 00:00:00 23:59:59 2 EE301218 08:05:35 20:56:35 MA301134 12:35:45 21:40:42 3 CS301111 15:30:28 17:00:10 SC3021234 08:00:00 11:25:25 CS301133 21:45:00 21:58:40

Sample Output


ME3021112225321 ME3021112225321 EE301218 MA301134 SC3021234 CS301133

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
const int maxn = 1000 + 66;
struct  student
{
char name[20];
int h, m, s;
int h1, m1, s1;
} a[maxn];
bool cmp1(student a,student b)
{
if (a.h < b.h)
return true;
else if (a.h > b.h)
return false;
else
{
if (a.m < b.m)
return true;
else if (a.m > b.m)
return false;
else
{
if (a.s < b.s)
return true;
else if (a.s > b.s)
return false;
}
}
return true;
}
bool cmp2(student a, student b)
{
if (a.h1 < b.h1)
return true;
else if (a.h1 > b.h1)
return false;
else
{
if (a.m1 < b.m1)
return true;
else if (a.m1> b.m1)
return false;
else
{
if (a.s1 < b.s1)
return true;
else if (a.s1 > b.s1)
return false;
}
}
return true;
}
int main()
{
int t;
while (scanf("%d",&t)!=EOF)
{
while(t--)
{
int m;
scanf("%d", &m);
int m1=m;
int id = 0;
while (m1--)
{
scanf("%s", a[++id].name);
scanf("%d:%d:%d ", &a[id].h, &a[id].m, &a[id].s);
scanf("%d:%d:%d", &a[id].h1, &a[id].m1, &a[id].s1);
}
sort(a + 1, a+m + 1,cmp1);
cout << a[1].name << " ";
sort(a + 1, a + m + 1, cmp2);
cout << a[m].name << endl;
}
}
}

# 排名

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 32662    Accepted Submission(s): 11974

Problem Description

Input

< 1000 )、考题数M ( 0 < M < = 10 )、分数线（正整数）G；第2行排序给出第1题至第M题的正整数分值；以下N行，每行给出一

（题目号由1到M）。

Output

Sample Input


4 5 25 10 10 12 13 15 CS004 3 5 1 3 CS003 5 2 4 1 3 5 CS002 2 1 2 CS001 3 2 3 5 1 2 40 10 30 CS001 1 2 2 3 20 10 10 10 CS000000000000000001 0 CS000000000000000002 2 1 2 0

Sample Output


3 CS003 60 CS001 37 CS004 37 0 1 CS000000000000000002 20

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;
const int maxn = 1000 + 66;
struct  student
{
char name[maxn];
int num;
}a[maxn];
bool cmp1(const student a, const student b)
{
else
{
return strcmp(a.name,b.name)<0;
}
return true;
}
int main()
{
int n, m, g;
while (scanf("%d %d %d", &n, &m, &g)&&n)
{
for (int i = 1; i <= m; i++)
{
}
for (int i = 1; i <= n; i++)a[i].grades=0;
int ans = 0;
for (int i = 1; i <= n; i++)
{
scanf("%s %d", a[i].name, &a[i].num);
for (int j = 1; j <= a[i].num; j++)
{
int id;
scanf("%d", &id);
}
{
ans++;
}
}
printf("%d\n", ans);
//cout << n << endl;
sort(a + 1, a + n + 1, cmp1);
for (int i = 1; i <= n; i++)
{
}
}
return 0;
}

©️2019 CSDN 皮肤主题: 技术工厂 设计师: CSDN官方博客