結果

問題 No.3081 Make Palindromic Multiple
ユーザー kaichou243
提出日時 2025-02-25 00:07:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,518 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 200,856 KB
実行使用メモリ 10,524 KB
最終ジャッジ日時 2025-03-27 13:23:17
合計ジャッジ時間 7,292 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 10 TLE * 1 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
ll qpow(ll a,ll n,ll mod){
	ll ret=1;
	while(n){
		if(n&1) ret=(ret*a)%mod;
		a=(a*a)%mod;
		n>>=1;
	}
	return ret;
}
vector<P> prime_factorize(ll N) {
    vector<P> res;
    for(ll a=2;a*a<=N;++a){
        if(N%a!=0) continue;
        ll ex=0;
        while(N%a==0){
            ++ex;
            N/=a;
        }
        res.push_back({a,ex});
    }
    if(N!=1) res.push_back({N,1});
    return res;
}
ll Euler_phi(ll n){
    vector<pair<ll,ll>> pf=prime_factorize(n);
    ll res=n;
    for(auto p : pf){
        res*=(p.first-1);
        res/=p.first;
    }
    return res;
}
int main(){
	ll n;
	cin >> n;
	if(n%2!=0&&n%5!=0){
	    cout << 1 << endl;
	    cout << 9 << ' ' << Euler_phi(n) <<endl;
	}else if(n%2==0){
	    for(ll x=n;x<=n*1000000;x+=n){
	        string s=to_string(x);
	        string t=s;
	        reverse(t.begin(),t.end());
	        if(s==t){
	            cout << 1 << endl;
	            cout << x << ' ' << 1 << endl;
	            return 0;
	        }
	    }
	}else{
	    for(ll x=n;x<=n*50000000;x+=n){
	        string s=to_string(x);
	        string t=s;
	        reverse(t.begin(),t.end());
	        if(s==t){
	            cout << 1 << endl;
	            cout << x << ' ' << 1 << endl;
	            return 0;
	        }
	    }
	}
}
/*
Nが2,5を素因数に持たない
→10^phi(n)-1
N=2^kや5^kがなんとかなるが(rev(str(2^k))00000...0str(2^k))、N=m2^kみたいなケースはどうするん?

*/
0