結果
問題 | No.136 Yet Another GCD Problem |
ユーザー |
![]() |
提出日時 | 2015-01-25 23:52:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 650 bytes |
コンパイル時間 | 1,324 ms |
コンパイル使用メモリ | 164,700 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 03:01:43 |
合計ジャッジ時間 | 2,410 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 25 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i,a,b) for(int i=a;i<(int)b;i++)#define rep(i,n) REP(i,0,n)map<int,int> pfact(int n) {map<int, int> ret;for(int i=2; i*i<=n; i++) {while(n%i == 0) {++ret[i]; n/=i;}}if(n!=1) ret[n] = 1;return ret;}int main() {int N, K; cin >> N >> K;K = min(N, K)-1;map<int, int> mp = pfact(N);long long ans = 1;for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++) {while(it->second > 0) {if(K > 0) {K --;}else {ans *= it->first;}it->second--;}}cout << ans << endl;return 0;}