编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#6498 #1082. 速算大师小 R Accepted 100 302 ms 392 K C++ 17 / 1.9 K san_bin_12138 2024-11-16 15:21:12
显示原始代码
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

const int maxn = 500;
//
int char2int(char a)  // char->int
{
    int n;
    n = int(a) - int('0');
    return n;
}
char int2char(int n)  // int->char
{
    char a;
    int x;
    x = n - int('0');
    a = char(x);
    return a;
}
//
string jia(string a, string b)  // c=a+b
{
    int i, x = 0;
    string c(maxn, '0');
    for (i = maxn - 1; i >= 0; i--) {
        x = char2int(a[i]) + char2int(b[i]) + x;
        c[i] = x % 10 + int('0');
        x = x / 10;
    }
    return c;
}
//
string cheng1(string a, char b)  // c=a*b,b为个位数
{
    int i, x = 0;
    string c(maxn, '0');
    char g;
    for (i = maxn - 1; i >= 0; i--) {
        x = char2int(a[i]) * char2int(b) + x;
        g = x % 10 + int('0');
        c[i] = g;
        x = x / 10;
    }
    return c;
}
//
string yi_wei(string a, int n)  // a=a*10^n
{
    int i;
    for (i = 0; i < maxn - n; i++) {
        a[i] = a[i + n];
    }
    for (i = maxn - n; i < maxn; i++) {
        a[i] = '0';
    }
    return a;
}
string cheng2(string a, string b)  // c=a*b
{
    int i, n;
    string x(maxn, '0'), c(maxn, '0');
    for (i = maxn - 1; i >= 0; i--) {
        x = cheng1(a, b[i]);
        x = yi_wei(x, maxn - i - 1);
        c = jia(x, c);
    }
    return c;
}
//
string kuai_su_mi(int r)  //计算2^r
{
    string s(maxn, '0'), m(maxn, '0');
    m[maxn - 1] = '2';
    s[maxn - 1] = '1';
    int d;
    while (r > 0) {
        d = r % 2;
        if (d == 1) {
            s = cheng2(s, m);
        }
        r = r / 2;
        m = cheng2(m, m);
    }
    return s;
}
//
void shu_chu(string s) {
    int i, j;
    for (j = 10; j >= 1; j--) {
        for (i = maxn - j * 50; i < maxn - (j - 1) * 50; i++) {
            cout << s[i];
        }
        cout << endl;
    }
}
//
int main() {
    int r;
    cin >> r;
    double n, R;
    R = double(r);
    n = log10(2) * R + double(1);
    cout << int(n) << endl;
    string s;
    s = kuai_su_mi(r);
    int x;
    char y;
    x = s[maxn - 1];
    y = x - 1;
    s[maxn - 1] = y;
    shu_chu(s);
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:17 ms
内存:272 KiB

输入文件(calculator0.in

29

答案文件(calculator0.out

9
00000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000
<421 bytes omitted>

用户输出

9
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
000000000000000000000000
<384 bytes omitted>

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:16 ms
内存:372 KiB

输入文件(calculator1.in

40

答案文件(calculator1.out

13
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000
<422 bytes omitted>

用户输出

13
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000
<385 bytes omitted>

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:18 ms
内存:304 KiB

输入文件(calculator2.in

38

答案文件(calculator2.out

12
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000
<422 bytes omitted>

用户输出

12
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000
<385 bytes omitted>

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:19 ms
内存:392 KiB

输入文件(calculator3.in

57

答案文件(calculator3.out

18
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000
<422 bytes omitted>

用户输出

18
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000
<385 bytes omitted>

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:31 ms
内存:352 KiB

输入文件(calculator4.in

999

答案文件(calculator4.out

301
00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000
<423 bytes omitted>

用户输出

301
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
0000000000000000000000
<386 bytes omitted>

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:26 ms
内存:360 KiB

输入文件(calculator5.in

777

答案文件(calculator5.out

234
00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000
<423 bytes omitted>

用户输出

234
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
0000000000000000000000
<386 bytes omitted>

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:30 ms
内存:384 KiB

输入文件(calculator6.in

638

答案文件(calculator6.out

193
00000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000
<423 bytes omitted>

用户输出

193
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
0000000000000000000000
<386 bytes omitted>

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:54 ms
内存:284 KiB

输入文件(calculator7.in

191981

答案文件(calculator7.out

57793
37043631511832551985940428339432671387574409281795
83498751270460657402916553789345583706532
<425 bytes omitted>

用户输出

57793
37043631511832551985940428339432671387574409281795
83498751270460657402916553789345583706532828470930
84470466508389035693
<388 bytes omitted>

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:45 ms
内存:252 KiB

输入文件(calculator8.in

70012

答案文件(calculator8.out

21076
11821930302572978271947318179247041024284823160000
76729356705200490301962595011848908183110
<425 bytes omitted>

用户输出

21076
11821930302572978271947318179247041024284823160000
76729356705200490301962595011848908183110501604664
72595350457144159739
<388 bytes omitted>

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:46 ms
内存:296 KiB

输入文件(calculator9.in

1000000

答案文件(calculator9.out

301030
62444600041932855783251617241085645011001036578193
2044662563145803751358661759583345107758
<426 bytes omitted>

用户输出

301030
62444600041932855783251617241085645011001036578193
20446625631458037513586617595833451077584170520402
2698031471290583891
<389 bytes omitted>

系统信息

Exited with return code 0