Search found 8 matches
- Tue Jun 21, 2005 9:09 pm
- Forum: Algorithms
- Topic: HELP: Factorials
- Replies: 3
- Views: 1389
tnx
Thank you all. I totally misunderstood the problem.
- Thu Jun 16, 2005 2:45 pm
- Forum: Algorithms
- Topic: HELP: Factorials
- Replies: 3
- Views: 1389
HELP: Factorials
I must find the last non zero digit of n!
#include <cstdio>
int find_last(int x) {
while (x%10==0) x/=10;
return x%10;
}
int fact(int x) {
int sol=1;
for (int i=1;i<=x;i++)
sol=find_last(find_last(i)*find_last(sol));
return sol;
}
int main(void)
{
int n;
scanf("%d",&n);
printf("%d\n ...
#include <cstdio>
int find_last(int x) {
while (x%10==0) x/=10;
return x%10;
}
int fact(int x) {
int sol=1;
for (int i=1;i<=x;i++)
sol=find_last(find_last(i)*find_last(sol));
return sol;
}
int main(void)
{
int n;
scanf("%d",&n);
printf("%d\n ...
- Sun Jun 12, 2005 2:41 pm
- Forum: Volume 1 (100-199)
- Topic: 147 - Dollars
- Replies: 233
- Views: 51004
tnx
It works...Tnx
- Thu Jun 09, 2005 6:40 pm
- Forum: Volume 1 (100-199)
- Topic: 147 - Dollars
- Replies: 233
- Views: 51004
I learned something new. You can't do this - float==something :D ,and I understand why you suggested EPS. Please PM the changed code so i can see what changes have you made...I was having MUCH trouble finding out my error, got tired and made BigNum -> got AC, so I think my error is not algorithmic ...
- Thu Jun 09, 2005 2:08 pm
- Forum: Volume 1 (100-199)
- Topic: 147 - Dollars
- Replies: 233
- Views: 51004
Re: 147 __int64 can't hold big results.Please help
if (input<EPS) break;
Program should stop if input<EPS...Why did you put "?"
My program had wrong results after last coin was used.That was because my coins array was wrong. The correct one is:
int coins[]={1, 2, 4, 10, 20, 40, 100, 200, 400, 1000, 2000 };
Finaly, my code was not accepted ...
- Thu Jun 09, 2005 2:14 am
- Forum: Volume 1 (100-199)
- Topic: 147 - Dollars
- Replies: 233
- Views: 51004
Re: 147 __int64 can't hold big results.Please help
CODE REMOVED
- Wed Jun 08, 2005 1:22 am
- Forum: Volume 1 (100-199)
- Topic: 147 - Dollars
- Replies: 233
- Views: 51004
147 __int64 can't hold big results.Please help
CODE REMOVED
- Tue May 17, 2005 11:08 pm
- Forum: Volume 6 (600-699)
- Topic: 601 - The PATH
- Replies: 20
- Views: 10070
601 WHY TLE?
#include <cstdio>
#include <string>
#include <iostream>
#define MAX 81
using namespace std;
int dx[]={ 1,0,0,-1};
int dy[]={ 0,-1,1,0};
int bio[MAX][MAX];
char mat[MAX][MAX];
int n,sol=0;
int ok(int x,int y)
{
if (x>=0 && x<n && y>=0 && y<n) return 1;
return 0;
}
void dfs(int x,int y,int col ...
#include <string>
#include <iostream>
#define MAX 81
using namespace std;
int dx[]={ 1,0,0,-1};
int dy[]={ 0,-1,1,0};
int bio[MAX][MAX];
char mat[MAX][MAX];
int n,sol=0;
int ok(int x,int y)
{
if (x>=0 && x<n && y>=0 && y<n) return 1;
return 0;
}
void dfs(int x,int y,int col ...