In the example 2 2 3, z==5. Why do everybody say that z==2? using System; class Entrypiont { static void Main() { string[] Input = Console.ReadLine().Split(' '); int a = Convert.ToInt32(Input[0]); int b = Convert.ToInt32(Input[1]); int c = Convert.ToInt32(Input[2]); if(((c-1)%a)==((c-1)%b) && ((c - 1) % a) == 0) { int x=1, y=1, z=1; while (true) { if(Math.Pow(x,a)+ Math.Pow(y, b)== Math.Pow(z, c)) { Console.Write(x); Console.Write(y); Console.Write(z); break; } else { if(Math.Pow(x, a) + Math.Pow(y, b) >Math.Pow(z, c)) { z++; } else { if (x >= y) { y++; } else { x++; }
} } } } Console.ReadLine(); } } Hi, i have problem with WA#52, I used long long and test 1 1 32 => accept. This's my code : #include <iostream> using namespace System; using namespace std; long long func( long long x , int po ); void main() { long long a,b,c,y,k,x,n,m; cin>>a>>b>>c; k = (c-1)/a; m = (c-1)/b; x = func( k ,2 ); y = func( m , 2 ); printf("%lld\n%lld\n2",x,y); system("pause"); } long long func( long long x , int po ) { long long temp=2; for( int i=1; i<x; i++ ) { temp *= po; } return temp; } Hi, I had WA 52 too, these tests helped me: 1) 1 1 1 2) 5 10 1 Edited by author 16.10.2016 19:50 why? here is the code: #include <iostream> #include <cmath> using namespace std; int main(){ long long X,Y,Z,k,l,m; short A,B,C; cin>>A>>B>>C; k=(C-1)/A; l=(C-1)/B; X=1;Y=1; for(long i=1;i<=k;i++) X*=2; for(long i=1;i<=l;i++) Y*=2; cout<<X<<" "<<Y<<" "<<"2"; return 0; } If you have WA51 you can use "long long" instead "int" in order to solve the problem. what about example? input 2 2 3 output 10 5 5 but 2*10+5*2!=5*3 ->20+10!=15 -> 30!=15 where im wrong? you need not 10*2+5*2=5*3, but 10^2+5^2=5^3 (100+25=125) omg, thanks a lot :) now im got AC Edited by author 03.09.2009 20:53 Hi I think there is a special formula for this problem. Can anybody ,who knows, post it, please? n=(c-1)/a; m=(c-1)b; Answer 2^n 2^m 2 n=(c-1)/a; m=(c-1)b; Answer 2^n 2^m 2 EASY PrOblem And IV, thank you very much. Edited by author 27.02.2007 00:36 Simple)) z = 2; So x^a+y^b=2^c => 2^(c-1) + 2^(c-1) == 2^(c-1)*(1+1) == 2^(c-1)* 2^1 = 2^(c-1+1) == 2^c; => x^a == 2^(c-1), y^b = 2^(c-1) => x == 2^((c-1)/a), y== 2^((c-1)/b). New tests were added. 77 authors lost AC. Don't know what kind of tests were added, but all I had to do is to change type of X,Y from int to __int64 in order to get AC again Only worse case is 1 1 32 -> And answer must be 2^32 > max_int My solution (and, as far as I know, author's one also) produces answers <= 2^31. When my soulution produced <= 2^31 I had Wa52. But when I changed it to <= 2^32 -> AC I think we speak about different things... You speak about type, in which result is stored. And I say that there is correct formula, which produces results <= 2^31. May be 2<<31 ? Yes. If you are used to C style. ^ is usual designation for power. yes I know (long long)2<<31 = int64(2 shl 31) = 2^32 it's max answer of my formula for test 1 1 32 which was added just 1 week ago [deleted] I got Accept. Edited by author 09.01.2007 23:57 a=1, b=1, c=31 => z = 2^30+1 x = (2*(2^30+1))^30 > 2^900 > 10^50 But in statements is said that answers should not exceed 10^50. Thanks. I understood my mistake. But am I in a right way, or I must think about somethink else ? Alright ;) Just invent another one formula. Mine produces numbers <= 2^31. On right way... If you want, I could give you the true formula!!! Thanks, but I got Accept:).Of course, if you want, you can help me with 1106, because after rejudging I had WA#11 :( Post your mail, I'll try to help you. Mail: w_soulreaver@ukr.net Thanks. |
|