求助,有一个测试集不通过
查看原帖
求助,有一个测试集不通过
1478087
ExileAurora楼主2024/10/17 11:29
#include<iostream>
using namespace std;

int ff(int n,int m)
{
	int sum = 1;
	for (int i = 1; i <= m; i++)
	{
		sum *= n;
	}
	return sum;
}

int main() 
{
	int a, b, cnt = 1, d, e = 0, temp,count = 0,arr[100],s = 0;
	cin >> a;
	for (int j = 0; j <= a - 1; j++)
	{
		cin >> arr[s];
		s++;
	}
	while (count != a)
	{
		cnt = 1;
		temp = arr[count];
		
		while (temp / 10 != 0)
		{
			temp = temp / 10;
			cnt++;
		}
		temp = arr[count];
		for (int i = 1; i <= cnt; i++)
		{
			if (temp / 10 != 0)
				d = temp - temp / 10 * 10;
			else
				d = temp;
			temp = temp / 10;
			e += ff(d, cnt);
		}
		if (arr[count] == 0)
			e = 1;
		if (e == arr[count])
			cout << 1 << endl;
		else
			cout << 0 << endl;
		e = 0;
		count++;
	}
	return 0;
}
2024/10/17 11:29
加载中...