|
|
10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 Ans:- 1681 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000 Ans:- 1271 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Ans:- 12870 You are very stupid!!! 0<ans<9 Don't repeat my mistake and remember that you must calculate prime numbers up to 10000 (not to 100!). Maybe this test will help you: 9797 1 1 1 1 1 1 1 1 1 Answer = 4 (9797 = 97 * 101) Sorry for my English :) Edited by author 04.04.2010 19:55 oh!!! thank you very much, i just calculate to sqrt(10000)... if you have WA in test4, you can try this. oh!!! thank you very much, i just calculate to sqrt(10000)... if you have WA in test4, you can try this. I just got accepted. It is enough to calc prime nums up to Num div 2. Because if Num not divided on any prime <= than Num div 2 then Num itself is a prime num. Edited by author 22.02.2023 12:10ilyas: Please don't call people stupid. Everyone makes mistakes; the author simply forgot to calculate modulo 10. Thanks for tests, I join. Input: 1 1 1 1 1 1 1 1 1 1 Output: 1 Input: 43 5 49 2 3 5 3 4 5 5 Output: 0 Input: 10000 10000 12 10000 10000 10000 13 10000 10000 29 Output: 2 Input: 99 101 102 103 104 105 106 107 108 109 Output: 6 My program passes all these test cases... Still I am getting wrong answer at 6th test. Hint: you should only know fundamental theorem of arithmetic It's easy if you know that number of divisors is (n_1+1)*(n_2+1)*...*(n_k+1), where n_i is power of prime that is included in number decomposition i really don't understand why i got WA #1...i try a lot of tests and i always have the right answer, could anyone give me test 1, please, thx~ Edited by author 26.04.2012 11:47 Edited by author 26.04.2012 11:48 #include<bits/stdc++.h> using namespace std; int main(){ long long a[10],l,s,z=1,q,f; vector<long long>v; vector<long long>p; bool prime[10000]; memset(prime,true,sizeof(prime)); for(int i=2;i<=10000;i++){ if(prime[i]){ for(int j=i*2;j<=10000;j=j+i){ prime[j]=false; } } } for(int i=2;i<=10000;i++){ if(prime[i]){ v.push_back(i); } } q=v.size(); f=v[q-1]; for(int i=2;i<=f;i++){ p.push_back(0); } for(int j=0;j<10;j++){ cin>>a[j]; } for(int i=0;i<10;i++){ l=0,s=0; while(a[i]>=v[l]){ if(a[i]%v[l]==0){ //cout<<a[i]<<" "<<v[l]<<endl; p[v[l]]++; a[i]=a[i]/v[l]; } else{ l++; } } } for(int i=0;i<=p.size();i++){ z=(z*(p[i]+1))%10000; } z=z%10; cout<<z; return 0; } Before sending your solution try this test on your pc and make sure that pc can calculate it faster than 10 hours :)) 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 1 I really don't understand why i got WA #12...i try a lot of tests and i always have the right answer, could anyone give me test 12, please. What's wrong? I have 'time limit excedeed' in 9th test. import functools def pr(n): result = [] i = 2 now = 1 while n >= 1: if n % i == 0: now *= i n //= i elif n % i != 0 and now > 1: result.append(now) i += 1 now = 1 else: i += 1 if n == 1: result.append(now) return result def f(n): result = 0 i = 1 while i ** 2 < n: if n % i == 0: result += 1 i += 1 if i ** 2 == n: return 2 * result + 1 else: return 2 * result newList = [int(input()) for _ in range(10)] product = functools.reduce((lambda x, y: x * y), newList) print(functools.reduce(lambda x, y: x * y, map(f, pr(product))) % 10) import java.util.*; public class BallonNumber { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a[]=new int[10]; int count=0; int prod=1,i; for(i=0;i<10;i++) { a[i]=sc.nextInt(); } for(i=0;i<10;i++) { prod=prod*a[i]; } //System.out.println(prod); for(i=1;i<=prod;i++) { if (prod%i==0) { count+=1;
} } System.out.println(count); } } So this is my code but it says wrong answer but I get the same answer in ide.What is wrong with this code Please estimate max value of prod. Then compare it with int capacity. var podschet,a,b,i:integer; begin a:=1; for i:=1 to 10 do begin readln(b); a:=a*b; end; for i:=1 to a do begin if a mod i=0 then podschet:=podschet+1; end; if podschet>9 then podschet:=podschet div 10; writeln(podschet); end. Edited by author 11.12.2014 15:46 Mistake is in this line: if podschet>9 then podschet:=podschet div 10; To take last digit you should be using mod instead of div. Edited by author 15.02.2015 23:31 Edited by author 15.02.2015 23:31 1.You only need to identify the number of divisors. So, follow this: http://mathschallenge.net/library/number/number_of_divisors 2.Getting the product and then getting the number of divisors is going to take a LOT of time than getting the number of each of the 10 divisors. -> This is an important trick. All the best. ElPsyCongroo. decomposed into prime factors, and then submit to the canonical form then you will get AC!!! It is a good idea! I used the same method! somebody know what is the test 3, I don't know what problem I have in my code; here is it #include <stdlib.h> #include <stdio.h> int main(){ int desicion[10]; int exponentes[1000]={0}; int i,j,valor=1; int numeroDivisores=1; int valorIteracion; int impresion; for(i=0;i<10;i++){ scanf("%i",&desicion[i]); valor*=desicion[i]; } i=2; j=0; while(valor!=1){ if(valor%i==0){ exponentes[j]++; valor=valor/i; }else{ i++; numeroDivisores=numeroDivisores*(exponentes[j]+1); j++; } } numeroDivisores=numeroDivisores*(exponentes[j]+1); numeroDivisores%=10; printf("%i\n",numeroDivisores); } this is my code so what is the crash error # include <iostream> # include <vector> using namespace std; const int maxN=10000+10; int p[maxN],t[maxN]; vector <int> v; int main () { int n,sum=1;
for (int i=2;i<=maxN;i++) for (int j=2*i;j<=maxN;j+=i) p[j]=1; for (int j=1;j<=10;j++) { cin>>n; for (int i=2;i<=n;i++) { int len = n; while (len>1 && !p[i] && len%i==0) { len/=i; v.push_back(i); } } }
for (int i=0;i<v.size();i++) t[v[i]]++; for (int i=2;i<maxN;i++) if (t[i]>0) { t[i]++; sum*=t[i]; sum%=10; } cout<<sum%10; //cin>>n; return 0; } #include<stdio.h> int arr[11]; int num = 1; int prime[10000]; int ans = 1; int main() { for( int j = 0 ; j< 10 ; j++ ) { scanf("%d",&arr[j]); if( arr[j] == 1 ) { continue; } for( int i = 2 ; i <= arr[j] ; i++ ) { while( arr[j] % i == 0 ) { prime[i]++; arr[j] = arr[j] /i; if( arr[j] == 1 ) { break; } } } }
for( int i = 2 ; i < 10001 ; i++ ) { ans *= (prime[i]+1) % 10 ; } ans = ans % 10; printf("%d\n",ans); //scanf("%d",&prime[0]); return 0; } here is my Code.. Removed After Getting AC Edited by author 20.02.2012 19:34 I think my code faster But only 4th test Is it? 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 And what will be correct answer this one? Thanks 10000 = 10^4=2^4*5^4 so 10000^10=2^40*5*40 so answer is 41*41 % 10 = 1 and what's test n#2 ??? Can someone please say why the hell is it wrong?:( #include<iostream> using namespace std; int main() { const int size=10; int pro[10]={0}; long long int magic=1; int licz=2; const int n=10000; bool numbersTable[n+1]={0}; int pierw[1229]; int w=0; //sito
for (int i = 2; i <= n; i++ ) { if (numbersTable[i] == true) continue; pierw[w++]=i; for (int j = 2 * i ; j <= n; j += i) numbersTable[j] = true; }
for(int i=0;i<size;i++) { cin>>pro[i]; magic*=pro[i]; }
int k=0; long long int z=0; licz=1; for(int i=0; i<1229; i++) {
if(magic/pierw[i]<1) break; k=0; z=magic; while(z%pierw[i]==0) {
z/=pierw[i]; k++; } licz*=(k+1);
} if (magic==1) licz=1;
cout << licz%10;
} Dear friend: Is not necessary multiply the input, working each a_i you can reduce the complexity I think, my solution is very tricky. It can be more simpler and smaller. How many lines of code your solution? I've just figured out that if a==p1^k1*p2^k2*...*pn^kn(where p_i are prime numbers) then (k1+1)*(k2+1)*...*(kn+1) amount of numbers devide a; so you can use this idea in this problem. I think its too strong hint! [hidden code:)] Edited by author 03.02.2011 14:33 |
|
|