C++入门同步记录#8

#include<cstdio>
using namespace std;
int main() {
    int n, k, A_sum, B_sum;
    scanf("%d%d", &n, &k);
    A_sum = k * (n / k) + ((n / k) * (n / k - 1) * k) / 2;
    B_sum = (1 + n) * n / 2 - A_sum;
    printf("%.1f ", double(A_sum) / (n / k));
    printf("%.1f", double(B_sum) / (n - n / k));
    return 0;
} 


/*#include<iostream>
using namespace std;
int main() {
    int a, days = 1;
    cin >> a;
    while (a > 1)
        days++, a /= 2;
    cout << days << endl;
    return 0;
}*/
#include<iostream>
using namespace std;
int main() {
    int a, days = 1;
    cin >> a;
    for (a; a > 1; a /= 2)
        days++;
    cout << days << endl;
    return 0;
}


#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main() {
    int ran;
    srand(time(0));
    ran = rand();
    cout << ran;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<ctime>
using namespace std;
int main() {
    int ans, guess;
    srand(time(0));
    ans = rand() % 100 + 1;
    do {
        cin >> guess;
        if (guess < ans)
            cout << "Too small" << endl;
        if (guess > ans)
            cout << "Too large" << endl;
    } while (ans != guess);
    cout << "You are right!!" << endl;
    return 0;
}



/*#include<cstdio>
using namespace std;
int main() {
    int n, num = 1;
    scanf("%d", &n);
    while (n > 0) {
        for (int i = 0; i < n; i++){
            printf("%02d", num);
            num += 1;
        }
        printf("\n");
        n--;
    }
    return 0;    
}*/


/*#include<cstdio>
using namespace std;
int main() {
    int cnt = 1, n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n - i + 1; j++)
            printf("%02d", cnt++);
        printf("\n");
    }
    return 0;
}*/


#include<cstdio>
using namespace std;
int main() {
    int cnt = 0, n, k, cn;
    scanf("%d", &n);
    k = n, cn = n;
    for (int i = 1; i <= n * (n + 1) / 2; i++) {
        printf("%02d", ++cnt);
        if (i == cn) {
            printf("\n");
            k--, cn += k;
        }    
    }
    return 0;
}



/* 3
1145 1419
1981 0
3000 4000 */
#include<bits/stdc++.h>
using namespace std;

string myfun(int x) {
    if (x > 0 && x <= 1199)
        return "Newbie";
    else if (x >= 1200 && x <= 1399)
        return "Pupil";
    else if (x >= 1400 && x <= 1599)
        return "Specialist";
    else if (x >= 1600 && x <= 1899)
        return "Expert";
    else if (x >= 1900 && x <= 2099)
        return "Candidate Master";
    else if (x >= 2100 && x <= 2399)
        return "Master";
    else if (x >= 2400 && x <= 2999)
        return "Grandmaster";
    else if (x >= 3000)
        return "Legendary Grandmaster";
}

int main() {
    int n;
    cin >> n;
    for (n; n > 0; n--){
        int past, now;
        cin >> past >> now;
        string s1,s2;
        s1 = myfun(past);
        s2 = myfun(now);
        if (s1 == s2 )
            cout << "No" << endl;
        else
            cout << s1 << " to " << s2 << endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值