結果

問題 No.2016 Countdown Divisors
ユーザー 沙耶花
提出日時 2022-07-22 21:34:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 3,979 ms
コンパイル使用メモリ 256,972 KB
最終ジャッジ日時 2025-01-30 12:06:37
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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