Accept: 1032 Submit: 2471
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
You are given two positive integers A and B in Base C. For the equation:
We know there always existing many non-negative pairs (k, d) that satisfy the equation above. Now in this problem, we want to maximize k.
For example, A="123" and B="100", C=10. So both A and B are in Base 10. Then we have:
(1) A=0*B+123
(2) A=1*B+23
As we want to maximize k, we finally get one solution: (1, 23)
The range of C is between 2 and 16, and we use 'a', 'b', 'c', 'd', 'e', 'f' to represent 10, 11, 12, 13, 14, 15, respectively.
Input
The first line of the input contains an integer T (T≤10), indicating the number of test cases.
Then T cases, for any case, only 3 positive integers A, B and C (2≤C≤16) in a single line. You can assume that in Base 10, both A and B is less than 2^31.
Output
Sample Input
Sample Output
Source
“高教社杯”第三届福建省大学生程序设计竞赛#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w",stdout)
#define fst first
#define snd second
typedef __int64 LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
const int MAXN = 1e2 + 5;
const int INF = 0x3f3f3f3f;
int T, N, M;
int c;
char a[MAXN], b[MAXN];
int get(char* s)
{
int t = 1, res = 0, len = strlen(s);;
for (int i = len - 1; i >= 0; i--, t *= c) {
if (s[i] >= 'a' && s[i] <= 'z')
res += (s[i] - 'a' + 10) * t;
else
res += (s[i] - '0') * t;
}
return res;
}
int main() {
#ifndef ONLINE_JUDGE
FIN;
// FOUT;
#endif // ONLINE_JUDGE
int cas = 0, res;
scanf("%d", &T);
while (T--) {
scanf("%s%s%d", a, b, &c);
int aa = get(a);
int bb = get(b);
printf("(%d,%d)\n", aa / bb, aa % bb);
}
return 0;
}
Accept: 1076 Submit: 1257
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
In this problem, we have f(n,x)=Floor[n/x]. Here Floor[x] is the biggest integer such that no larger than x. For example, Floor[1.1]=Floor[1.9]=1, Floor[2.0]=2.
You are given 3 positive integers n, L and R. Print the result of f(n,L)+f(n,L+1)+...+f(n,R), please.
Input
The first line of the input contains an integer T (T≤100), indicating the number of test cases.
Then T cases, for any case, only 3 integers n, L and R (1≤n, L, R≤10,000, L≤R).
Output
Sample Input
Sample Output
Source
“高教社杯”第三届福建省大学生程序设计竞赛#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#define FIN freopen("input.txt","r",stdin)
#define FOUT freopen("output.txt","w",stdout)
#define fst first
#define snd second
typedef __int64 LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
const int MAXN = 1e7 + 5;
const int INF = 0x3f3f3f3f;
int T, N, M;
int main() {
#ifndef ONLINE_JUDGE
FIN;
// FOUT;
#endif // ONLINE_JUDGE
int cas = 0, res;
int L, R;
scanf ("%d", &T);
while (T --) {
res = 0;
scanf ("%d %d %d", &N, &L, &R);
for (int i = L; i <= R; i++) {
res += N / i;
}
printf ("%d\n", res);
}
return 0;
}
Accept: 372 Submit: 806
Time Limit: 1000 mSec Memory Limit : 32768 KB
Problem Description
Cao Cao was hunted down by thousands of enemy soldiers when he escaped from Hua Rong Dao. Assuming Hua Rong Dao is a narrow aisle (one N*4 rectangle), while Cao Cao can be regarded as one 2*2 grid. Cross general can be regarded as