結果

問題 No.358 も~っと!門松列
ユーザー threepipes_sthreepipes_s
提出日時 2016-04-17 22:34:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 1,000 ms
コード長 3,594 bytes
コンパイル時間 2,407 ms
コンパイル使用メモリ 83,036 KB
実行使用メモリ 50,600 KB
最終ジャッジ日時 2024-04-15 02:19:11
合計ジャッジ時間 4,258 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
50,504 KB
testcase_01 AC 52 ms
50,308 KB
testcase_02 AC 51 ms
50,020 KB
testcase_03 AC 52 ms
50,164 KB
testcase_04 AC 50 ms
50,544 KB
testcase_05 AC 50 ms
50,364 KB
testcase_06 AC 50 ms
50,444 KB
testcase_07 AC 51 ms
50,520 KB
testcase_08 AC 52 ms
50,496 KB
testcase_09 AC 52 ms
50,524 KB
testcase_10 AC 53 ms
50,304 KB
testcase_11 AC 52 ms
50,420 KB
testcase_12 AC 50 ms
50,544 KB
testcase_13 AC 50 ms
50,300 KB
testcase_14 AC 50 ms
50,204 KB
testcase_15 AC 51 ms
50,384 KB
testcase_16 AC 51 ms
50,200 KB
testcase_17 AC 51 ms
50,492 KB
testcase_18 AC 51 ms
50,352 KB
testcase_19 AC 51 ms
50,600 KB
testcase_20 AC 50 ms
50,420 KB
testcase_21 AC 52 ms
50,548 KB
testcase_22 AC 52 ms
50,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
	IOException {Main solve = new Main();solve.solve();}
	void dump(int[]a){for(int i=0;i<a.length;i++)System.out.print(a[i]+" ");System.out.println();}
	void dump(int[]a,int n){for(int i=0;i<a.length;i++)System.out.printf("%"+n+"d",a[i]);System.out.println();}
	void dump(long[]a){for(int i=0;i<a.length;i++)System.out.print(a[i]+" ");System.out.println();}
	void dump(char[]a){for(int i=0;i<a.length;i++)System.out.print(a[i]);System.out.println();}
	long pow(long a,int n){long r=1;while(n>0){if((n&1)==1)r*=a;a*=a;n>>=1;}return r;}
	String itob(int a,int l){return String.format("%"+l+"s",Integer.toBinaryString(a)).replace(' ','0');}
	int binarySearchSmallerMax(int[]a,int v) // get maximum index which a[idx]<=v
	{int l=0,r=a.length-1,s=0;while(l<=r){int m=(l+r)/2;if(a[m]>v)r=m-1;else{l=m+1;s=m;}}return a[s]>v?-1:s;}
	void solve() throws NumberFormatException, IOException{
		final ContestScanner in = new ContestScanner();
		Writer out = new Writer();
		int ans = 0;
		int[] a = new int[3];
		for(int i=0; i<3; i++) a[i] = in.nextInt();
		for(int i=1; i<=1000; i++){
			if(isK(a, i)) ans++;
		}
		if(isK(a, 1001)){
			System.out.println("INF");
		}else{
			System.out.println(ans);
		}
	}
	
	boolean isK(int[] a, int p){
		for(int i=0; i<3; i++){
			if(a[i]%p==a[(i+1)%3]%p) return false;
		}
		return a[1]%p>a[0]%p && a[1]%p>a[2]%p || a[1]%p<a[0]%p && a[1]%p<a[2]%p;
	}
}

class MultiSet<T> extends HashMap<T, Integer>{
	@Override
	public Integer get(Object key){return containsKey(key)?super.get(key):0;}
	public void add(T key,int v){put(key,get(key)+v);}
	public void add(T key){put(key,get(key)+1);}
	public void sub(T key)
	{final int v=get(key);if(v==1)remove(key);else put(key,v-1);}
}
class Timer{
	long time;
	public void set(){time=System.currentTimeMillis();}
	public long stop(){return time=System.currentTimeMillis()-time;}
	public void print()
	{System.out.println("Time: "+(System.currentTimeMillis()-time)+"ms");}
	@Override public String toString(){return"Time: "+time+"ms";}
}
class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner {
	private InputStreamReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new InputStreamReader(System.in);}
	public ContestScanner(String filename)throws IOException
	{in=new InputStreamReader(new FileInputStream(filename));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
}
0