結果
問題 |
No.3115 One Power One Kill
|
ユーザー |
|
提出日時 | 2025-04-19 15:59:28 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 248 ms / 2,000 ms |
コード長 | 1,760 bytes |
コンパイル時間 | 3,009 ms |
コンパイル使用メモリ | 85,516 KB |
実行使用メモリ | 75,804 KB |
平均クエリ数 | 2.00 |
最終ジャッジ日時 | 2025-04-19 15:59:37 |
合計ジャッジ時間 | 9,359 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main implements Runnable { public static void main(String[] args) { new Thread(null, new Main(), "", 512 * 1024 * 1024).start(); } long powmod(long a, long n, long mod) { if(n==0) return 1; return powmod(a*a%mod,n/2,mod)*(n%2==1?a:1)%mod; } long gcd(long a,long b) { if(a==0)return b; return gcd(b%a,a); } boolean[] isPrime=new boolean[100000]; int[] phi=new int[100000]; int[] f=new int[100000]; { Arrays.setAll(phi, i->i); Arrays.fill(isPrime, true); isPrime[0]=isPrime[1]=false; Arrays.fill(f, 1); for(int i=2;i<isPrime.length;++i) { if(isPrime[i]) { for(int j=2*i;j<isPrime.length;j+=i) { isPrime[j]=false; } for(int j=i;j<isPrime.length;j+=i) { phi[j]-=phi[j]/i; f[j]*=i; } } } } public void run() { long mod=(long)1e9+7; Scanner sc=new Scanner(System.in); // for(int B=100;B<=100000;++B) { // int A=phi[B]; // long Y=powmod(A,B,mod); // if(Y%f[B]!=0)continue; // tr(A,B); // } int A=102; int B=206; // for(int i=0;i<B;++i) { // if(i%2==0&&i%103==1)tr("!",i); // if(i%103==0&&i%2==1)tr("!",i); // } System.out.println(A+" "+B); int K=sc.nextInt(); if(K%206==0) { System.out.println(0); } else if (K%2==0) { System.out.println(104); } else if (K%103==0) { System.out.println(103); } else { System.out.println(1); } } void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));} }