Что означает отношения квадрата и куба и что за число n [code deleted] Edited by moderator 27.07.2023 17:22 I know that 12th test is so big. Maybe it will help you Edited by author 19.09.2012 02:57 the solution in C++ gave WA12, but the same algorithm in Python gave AC. I think, overflow is comming. //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("avx") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; using namespace std;
#define re return #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin())
template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; typedef tree <pair<int, char>, null_type, less<pair<int, char>>, rb_tree_tag, tree_order_statistics_node_update> _tree; map <int, int> m; void get (int x) { for (int i = 2, end = sqrt(x) + 1; i <= end; ++i) { if (x % i == 0) { m[i]++; x /= i; if (x > 1) get(x); re; } } if (x > 1) m[x]++; } int main() { ull n, _m = 1, k = 1; cin >> n; if (n == 1) { cout << "1\n1\n"; re 0; } get(n); for (auto j : m) { //cout << j.fi << ' '<< j.se << endl; if (j.se & 1) { k *= j.fi; j.se += 3; } j.se /= 2; fo(i, j.se) _m *= j.fi; } cout << _m << '\n' << k << endl; re 0; } It's very easy problem, but many people don't understand how to solve it ... :) 7 lines : #include <iostream> using namespace std; int main(){ unsigned long long N; cin >> N; cout << N*N << endl << N; return 0; } 5 lines: #include <iostream> void main() { unsigned long long N; std::cin >> N; std::cout << N*N << std::endl << N; } 4 lines: public class solver { public static void main(String[] args) { long n = new java.util.Scanner(System.in).nextInt(); System.out.println(n*n + "\n"+n);}} var n:int64; begin read(n); writeln(n*n); write(n) end. Edited by author 06.10.2014 22:49 OMG, i made prime factorization of n, searching for odd powers, multiplying to get k got AC, but now I see it was not neccassary Also for 18 i got 12 and 2, as in example. Edited by author 27.11.2015 02:00 1 line, no ";" tricks to put multiple lines into one :) print (lambda x : str(int(x) * int(x)) + '\n' + x)(raw_input()) #include<iostream> #include<stdlib.h> #include<math.h> using namespace std; int main() {long double n; long long int m,i; cin>>m;
for(i=1;i<10000000000000000000;i++) { n=sqrt(i*i*i*m); if(n==floor(n+0.5)) { cout<<n<<endl<<i;break;} } fflush(stdin); getchar(); return 0;} #include<iostream> using namespace std; int main() { double n; long long int m,i; cin>>m;
for(i=1;i<10000000000000000000;i++) { n=sqrt(i*i*i*m); if(n==floor(n+0.5)) { cout<<n<<endl<<i; break; } } fflush(stdin); getchar(); return 0; } #include <stdio.h> int main(){ long long int t; scanf("%lld", &t); printf("%lld\n%lld", t*t, t); return 0; } AC with MS VC, but WA 1 with GCC. Can anybody explain me what's wrong with my code? u should use %i64d instead %lld with GCC ;) Edited by author 12.07.2013 19:50 you must print n^2 and n. Why n = 18; m = 12, k = 2; When n = 18; m = 324, k = 18; Edited by author 21.04.2011 20:52 Why do you think, that there is the only solution? The obvious solution is too simple. You should ask for the smallest numbers. That solution is also easy enough, so it shouldn't be a problem for most people. Anyway, maybe the purpose of this problem is to teach people to use __int64. In that case simpler is better :) Edited by author 22.02.2009 21:50 OMFG. :D At first I solved it with about 50 strings of code. But after AC I catcha the 5-strings solution. :D "324 18" - wrong answer "324\n18" - accepted Judges, is it normal? And, it's all that I've to speak to you. ** sorry for my bad english.. :D Edited by author 24.07.2008 22:05 #include <iostream> #include <math.h> using namespace std; unsigned long long n,b,c,k,m; long double f,i; int main () { cin >>n; b=2; if (modf(sqrt((double)n),&i)==0) {cout <<(unsigned long long)sqrt((double)n)<<"\n"; cout <<"1"<<"\n";} else { for ( ;b<=n;b++) { f=modfl(sqrt((long double)n*(double)(b*b*b)),&i); if (f==0) break; } m=(unsigned long long )sqrt((long double)n*(double)(b*b*b)); cout <<m<<"\n"; cout <<b<<"\n"; } return 0; } Are u crazy? :) I had WA12 when I wrote v*v for integer v - it overflowed. Perhaps your long double (equals double for VC++) overflows too. Try putting everything into __int64, no floating point. I use prime factorization for that. you can write any numbers which can answer the condition but didn't smallest smallest are also easy :) why get 'ac' used ""pascl"" var n:int64; begin readln(n); writeln(n*n); writeln(n); end. --------------------------------- but: #include<stdio.h> int main() { unsigned long long n; scanf("%lld",&n); printf("%lld\n",n*n); printf("%lld\n",n); return 0; } who could tell me when i use "c",get "wa"? i am confused;
read FAQ for long long you should use %I64d help me++++++++ Probably you output it in one string? [code deleted] Edited by moderator 23.06.2006 17:18 I submited your program, it really have WA 12, but when I changed 'extended' to 'int64' it has got AC. Edited by author 01.04.2005 20:06 Edited by author 01.04.2005 20:06 I do not know such type 'int64'. How him to set? It's AC modification of your program. Here was AC solution :) Please, write me when you read I will delete it. Edited by author 02.04.2005 03:09 You very good person! but But, At me in pascal gives out a mistake (3)! Why? in tpx7 this type is not work. Try delphi or free pascal How to enter the data? How to deduce the data? You ask about using Delphi? or about using type int64 in it? New -> ... Console Application. I do not remember exactly, because I use c++, but I did so in past. Than you will to wright all like in TP7, but many features will be added. For exaple type int64. Sorry for poor English ;) Edited by author 02.04.2005 16:52 Got AC. Just use int64. Let m=n^2,k=n,then it's so easy.... Edited by author 17.06.2006 14:48 Can I see your AC program?I can't solve it. My email:charlie-wang-72@163.com |
|