結果

問題 No.443 GCD of Permutation
ユーザー kotatsugamekotatsugame
提出日時 2020-03-04 11:12:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 65,528 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 01:03:36
合計ジャッジ時間 1,964 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 2 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
string s;
main()
{
	cin>>s;
	bool all=true;
	for(int i=0;i<s.size();i++)all=all&&s[i]==s[0];
	if(all)
	{
		cout<<s<<endl;
		return 0;
	}
	int sum=0;
	for(int i=0;i<s.size();i++)sum+=s[i]-'0';
	int ans=1;
	if(sum%9==0)ans=9;
	else if(sum%3==0)ans=3;
	int t=8;
	bool f5=true,f7=true;
	for(int i=0;i<s.size();i++)
	{
		int c=s[i]-'0';
		if(c%8==0);
		else if(c%4==0)
		{
			if(t==8)t=4;
		}
		else if(c%2==0)
		{
			if(t>2)t=2;
		}
		else t=1;
		if(c%5!=0)f5=false;
		if(c%7!=0)f7=false;
	}
	ans*=t;
	if(f5)ans*=5;
	if(f7)ans*=7;
	cout<<ans<<endl;
}
0