"高教社杯"第三届福建省大学生程序设计竞赛

 A.Problem 2102 Solve equation

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:

A=k*B+d

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

For each test case, output the solution “(k,d)” to the equation in Base 10.

 Sample Input

32bc 33f 16123 100 101 1 2

 Sample Output

(0,700)(1,23)(1,0)

 Source

“高教社杯”第三届福建省大学生程序设计竞赛

题意:给你两个数,他们是任意进制的,进制要求已经限制在2进制和16进制之间,然后求解让A = k* B + d这个等式成立的最大的k值。
解题思路:将A, B两个数先转换为十进制(因为题目要求最终输出的k和d的值必须是十进制的),然后对A % B = d,求解出d的值,然后k = (A - d) / B,即可。
#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;
}

 C.Problem 2104 Floor problem

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

For each test case, print the result of f(n,L)+f(n,L+1)+...+f(n,R) in a single line.

 Sample Input

31 2 3100 2 100100 3 100

 Sample Output

0382332

 Source

“高教社杯”第三届福建省大学生程序设计竞赛

题意:求解给定数N,在[L,R]区间中的floor(N / i)的和
解题思路:直接暴力循环求和即可
#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;
}
 F.Problem 2107 Hua Rong Dao

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值