結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー kotatsugamekotatsugame
提出日時 2020-10-09 22:45:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 66,300 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-30 14:43:54
合計ジャッジ時間 1,551 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,504 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 22 ms
4,376 KB
testcase_09 AC 22 ms
4,380 KB
testcase_10 AC 24 ms
4,376 KB
testcase_11 AC 22 ms
4,376 KB
testcase_12 AC 24 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 32 ms
4,376 KB
testcase_15 AC 24 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int T,N;
long modpow(long a,long b,long M){return b?modpow(a*a%M,b/2,M)*(b%2?a:1)%M:1;}
main()
{
	cin>>T;
	for(int i=1;i<=T;i++)
	{
		cin>>N;
		int ans=1;
		int M=N=2*N-1;
		for(int j=2;j*j<=M;j++)
		{
			if(M%j==0)
			{
				int t=1;
				while(M%j==0)
				{
					M/=j;
					t*=j;
				}
				ans*=t-t/j;
			}
		}
		if(M>1)ans*=M-1;
		int X=ans;
		for(int i=1;i*i<=X;i++)
		{
			if(X%i==0)
			{
				if(ans>i&&modpow(2,i,N)==1)ans=i;
				if(i!=X/i&&ans>X/i&&modpow(2,X/i,N)==1)ans=X/i;
			}
		}
		cout<<ans<<endl;
	}
}
0