80分 #4 WA
查看原帖
80分 #4 WA
1167240
syman_liu楼主2024/1/13 13:09

各位大佬,本蒟蒻又来请教问题了

P1603 80分 #4 WA,原因:

too short on line 1

代码如下

#include <bits/stdc++.h>
using namespace std;

string num1[25] = {"","one","two","three","four","five","six ","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
string num2[5] = {"","a","another","first"};
string num3[5] = {"","both","second"};
string num4 = "third";
int ans[10];

int main()
{
	int cnt = 0;
	for (int i = 1;i <= 6;i ++)
	{
		string s;
		cin >> s;
		for (int j = 1;j <= 20;j ++)
		{
			if (s == num1[j]) ans[++ cnt] = j;
		}
		for (int j = 1;j <= 3;j ++)
		{
			if (s == num2[j]) ans[++ cnt] = 1;
		}
		for (int j = 1;j <= 3;j ++)
		{
			if (s == num3[j]) ans[++ cnt] = 2;
		}
		if (s == num4) ans[++ cnt] = 3;
	}
	if (cnt == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1;i <= cnt;i ++)
	{
		ans[i] = ans[i] * ans[i] % 100;
	}
	sort(ans + 1,ans + cnt + 1);
	for (int i = 1;i <= cnt;i ++)
	{
		if (i != 1 and ans[i] < 10) cout << 0;
		cout << ans[i];
	}
	return 0;
}

谢谢各位大佬!

2024/1/13 13:09
加载中...