Good Bye 2015

传送门:
http://codeforces.com/contest/611/problem/A
这题刚开始写的时候是硬算的,由于马虎把星期日算错了,其实直接暴力就ok了

// Days (A), by Errichto
#include<bits/stdc++.h>
using namespace std;

int t[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
    int x;
    scanf("%d", &x);
    char sl[15];
    scanf("%s", sl);
    scanf("%s", sl);
    if(sl[0] == 'w') {
        int current = 5;
        int ans = 0;
        for(int i = 0; i < 366; ++i) {
            if(current == x) ++ans;
            ++current;
            if(current > 7) current = 1;
        }
        printf("%d\n", ans);
        return 0;
    }
    int c = 0;
    for(int i = 0; i < 12; ++i) c += x <= t[i];
    printf("%d\n", c);
    return 0;
}

传送门:
http://codeforces.com/contest/611/problem/B

这道题目我的想法是和标解一样的,但是实际打的时候1个是没写1LL,1个是在用dev的时候用了%64d,坑啊,调试了好长时间,最后是因为这个原因导致输入的r区间刚开始就是错的,
下次调试的时候一定要注意这一点了,中间加上输出也是十分必要的,还有就是有的时候加法和减法一定要挑方便的用,比如这道题就应该用减法,我写的就是分丑陋

// One zero, by Errichto
// O(log^2(n))
#include<bits/stdc++.h>
using namespace std;

int main() {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    int c = 0;
    for(int i = 0; (1LL << i) / 2 <= b; ++i)
        for(int j = 0; j <= i - 2; ++j) {
            long long x = (1LL << i) - 1 - (1LL << j);
            c += a <= x && x <= b;
        }
    printf("%d\n", c);
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值