結果

問題 No.1728 [Cherry 3rd Tune] Bullet
ユーザー kotatsugamekotatsugame
提出日時 2021-11-06 04:29:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 79,212 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:08:32
合計ジャッジ時間 1,909 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 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 AC 2 ms
5,376 KB
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 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 54 ms
5,376 KB
testcase_24 AC 35 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int T,N,C;
int cnt[10000];
main()
{
	cin>>T;
	for(;T--;)
	{
		cin>>N>>C;
		vector<int>d;
		for(int p=1;p*p<=N;p++)if(N%p==0)
		{
			d.push_back(p);
			if(p<N/p)d.push_back(N/p);
		}
		sort(d.begin(),d.end());
		mint ans=mint(C).pow(N)*N;
		for(int i=d.size();i--;)
		{
			cnt[i]=N/d[i];
			for(int j=i+1;j<d.size();j++)if(d[j]%d[i]==0)cnt[i]-=cnt[j];
			ans+=mint(C).pow(2*d[i])*cnt[i];
		}
		cout<<(ans/(2*N)).val()<<endl;
	}
}
0