結果

問題 No.825 賢いお買い物
ユーザー heyanxx
提出日時 2019-07-04 15:39:18
言語 Java
(openjdk 23)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,142 bytes
コンパイル時間 3,061 ms
コンパイル使用メモリ 77,080 KB
実行使用メモリ 37,240 KB
最終ジャッジ日時 2024-09-19 03:57:48
合計ジャッジ時間 4,957 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

package test.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Yukicoder825 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		try {
			String[]str2=input();

			int a=Integer.parseInt(str2[0]);
			int b=Integer.parseInt(str2[1]);
			int c=Integer.parseInt(str2[2]);
			
			if(test(a,b,c)<=0) {
				System.out.println("Impossible");
			}else {
				System.out.println(test(a,b,c));
			}

		} catch (IOException e) {
		}	

	}
	
	public static int test(int a,int b, int c) {
	  int count =a+b*10;
	  int k=0;
	  int en=0;
	  if(c==0) {  
		  return a+b*10;
	  }else {
	  
	  for(int i=c;i>=0;i--) {
		  if(count-((c-i)*10+i)<=0 || ((c-i))*10+i<=0) {
			  continue;
		  }
		  
		  k=(count-((c-i)*10+i));
		  en=i;
	  }	
	  if((en-a)>=10) {
		  return -1;
	  }

		return k;
	
		//(a-(c-(a/10-1+b)))%10;
	  }
	}
	
	public static  String[] input() throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		
		String str=br.readLine();
		String[]str2=str.split(" ");
		
		return str2;
	}

}
0