Codeforces #30 A "Accounting"
問題:http://codeforces.com/contest/30/problem/A
本番.
全然わからなかったのでXの値を総当たり.
import java.util.*; public class A_Accounting { public static void main(String[] args) { Scanner s = new Scanner(System.in); int a=s.nextInt(),b=s.nextInt(),n=s.nextInt(); for(int i=0;i<1001;++i){ if(a*Math.pow(i,n)==b){ System.out.println(i); return; }else if(a*Math.pow(-i,n)==b){ System.out.println(-i); return; } } System.out.println("No solution"); } }