ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1049. Brave Balloonists

See my solution (- AC 0.015-245 KB) !
Posted by Gerasim Petrov Velchev 24 Jul 2008 14:35
My solution is very intelligent!
After every read number, we make factorization of it.
Every number is smaller than 10000.
We have array fact with 10000 elements and this array is global, because every elements are zero when we declare it.
When we make factorization of every divisor p (for factorization), we increase the p-th element in the array.
In the end of reading in array fact we have how many times is used i-th element in factorization - we have factorization of the whole product.
With one looking the array we calculate the amount of divisors with the so famous formula:
N=p[1]k[1]*p[2]k[2]*p[3]*k[3]*..., when p[i] is prime number , k[i] is amount of p[i] in factorization of N.
The amount of divisors is:(k[1]+1)*(k[2]+1)*(k[3]+1)*... .
See it!
//Brave-balloonists
#include<iostream>
using namespace std;
int fact[10000];
int main () {
int a;
for (int i=0;i<10;i++) {
int a;
cin>>a;
if (a!=1)
   {
int p=1,st=1;
while (a!=1)           {
p+=st;
while (a%p==0) {
a/=p;
fact[p]++;
               }
if (p==2) {p=1;st=2;}
                       }
  }
}
int br_del=1;
for (int i=0;i<10000;i++) br_del*=(fact[i]+1);
printf("%d\n",br_del%10);
return 0;
}
Re: See my solution (- AC 0.015-245 KB) !
Posted by AnyoneNeedingHelp 31 Oct 2008 12:23
you must delete it.