zoukankan      html  css  js  c++  java
  • An easy problem

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2132

    #include <iostream>
    #include <cstdio>
    #define ll long long
    
    using namespace std;
    
    const int N = 100005;
    ll table[N];
    // 打表 , table 和 变量i都要用long long 型,不然要自己转一下
    void meter() {
        table[0] = 0;
        for (ll i = 1; i < N; i++) {
            if (i%3==0) table[i] = table[i-1]+i*i*i;// 不用long long 的话,这里会超范围
            else table[i] = table[i-1]+i;
        }
    }
    
    int main() {
        int n;
        meter();
        while(~scanf("%d", &n) && n >= 0) {
             // 不能写 n != -1 , 题目原话是 “when n is a negative indicate the end of file.” 
            printf("%lld
    ", table[n]);
        }
        return 0;
    }

    。。。。。。。。2020过年闲的蛋疼

  • 相关阅读:
    *args, **kwargs
    python format函数
    python自省
    生成器与迭代器
    python面试题
    xpath和gzip
    python正则表达式
    cookie
    random
    杭电1710 (已知二叉树前中序 求后序)
  • 原文地址:https://www.cnblogs.com/hello-dummy/p/12298697.html
Copyright © 2011-2022 走看看