結果

問題 No.2016 Countdown Divisors
ユーザー 沙耶花沙耶花
提出日時 2022-07-22 21:34:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 4,605 ms
コンパイル使用メモリ 264,872 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 09:04:20
合計ジャッジ時間 8,325 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 172 ms
4,380 KB
testcase_02 AC 173 ms
4,380 KB
testcase_03 AC 156 ms
4,376 KB
testcase_04 AC 136 ms
4,376 KB
testcase_05 AC 131 ms
4,376 KB
testcase_06 AC 48 ms
4,380 KB
testcase_07 AC 47 ms
4,380 KB
testcase_08 AC 165 ms
4,376 KB
testcase_09 AC 167 ms
4,376 KB
testcase_10 AC 165 ms
4,380 KB
testcase_11 AC 170 ms
4,380 KB
testcase_12 AC 165 ms
4,376 KB
testcase_13 AC 142 ms
4,380 KB
testcase_14 AC 136 ms
4,376 KB
testcase_15 AC 137 ms
4,380 KB
testcase_16 AC 152 ms
4,380 KB
testcase_17 AC 148 ms
4,376 KB
testcase_18 AC 153 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

map<int,int> mp;

bool check(int N){
	int ok = 0,ng = 40000;
	while(ng-ok>1){
		int m = (ok+ng)/2;
		if(m*m<=N)ok = m;
		else ng = m;
	}
	return N==ok*ok;
}

int get(int N){
	
	if(mp.count(N))return mp[N];
	int ret = 0;
	for(int i=1;i*i<=N;i++){
		if(N%i==0){
			ret++;
			if(i*i!=N)ret++;
		}
	}
	mp[N] = ret;
	return ret;
}

int main(){
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		int N;
		cin>>N;
		if(N>=10){
			cout<<2<<endl;
			continue;
		}
		while(N!=get(N)){
			N -= get(N);
		}
		
		cout<<N<<endl;
		
	}
    return 0;
}
0