http://codeforces.com/contest/716/problem/C

题目大意:感觉这道题还是好懂得吧。

思路:不断的通过列式子的出来了。首先我们定义level=i, uplevel = i + 1,目前的uplevel,然后我们可以知道,之前求出来的restgrade%level = 0,于是我们可以列出一个式子sqrt(k1 * i + grade) = uplevel * k.因为grade也是i的倍数,假定grade = k2 * i,所以我们写成sqrt((k1 + k2) * i) = uplevel * k,所以两边平方再移项以后就可以发现总有这样的一个解满足条件,即:k1 = level * uplevel * uplevel - k2。然后我们打表一下:

//看看会不会爆int!数组会不会少了一维!
//取物问题一定要小心先手胜利的条件
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define haha printf("haha\n") int main(){
LL n;
LL level = , grade = ;
LL k1, k2, k;
scanf("%I64d", &n);
for (LL uplevel = ; uplevel <= n + ; uplevel++){
k2 = grade / level;
///printf("k2 = %I64d\n", k2);
k1 = level * uplevel * uplevel - k2;
grade = sqrt((k1 + k2) * level);
///printf("grade = %I64d %I64d %I64d\n", grade, grade / level , uplevel);
level++;
printf("%I64d\n", k1);
}
return ;
}

我们发现grade总等于level * uplevel,所以我们就可以求得level,然后看到level=1的时候不满足条件,然后特判一下就好了

//看看会不会爆int!数组会不会少了一维!
//取物问题一定要小心先手胜利的条件
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define haha printf("haha\n") int main(){
LL n;
LL level = , grade = ;
LL k1, k2, k;
scanf("%I64d", &n);
cout << << endl;
for (LL i = ; i <= n; i++){
printf("%I64d\n", (i + ) * (i + ) * i - i + );
}
return ;
}

Codeforces Round #372 (Div. 2) C 数学的更多相关文章

  1. Codeforces Round #372 (Div. 2)

    Codeforces Round #372 (Div. 2) C. Plus and Square Root 题意 一个游戏中,有一个数字\(x\),当前游戏等级为\(k\),有两种操作: '+'按钮 ...

  2. Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word

    Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...

  3. Codeforces 715A & 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))

    C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  4. Codeforces 715B & 716D Complete The Graph 【最短路】 (Codeforces Round #372 (Div. 2))

    B. Complete The Graph time limit per test 4 seconds memory limit per test 256 megabytes input standa ...

  5. Codeforces 716A Crazy Computer 【模拟】 (Codeforces Round #372 (Div. 2))

    A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. Codeforces 716B Complete the Word【模拟】 (Codeforces Round #372 (Div. 2))

    B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  7. Codeforces Round #372 (Div. 1) A. Plus and Square Root 数学题

    A. Plus and Square Root 题目连接: http://codeforces.com/contest/715/problem/A Description ZS the Coder i ...

  8. A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】

    题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...

  9. Codeforces Round #549 (Div. 2) D 数学

    https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位 ...

随机推荐

  1. CSU 1639 队长,我想进集训队!

    水题 #include<cstdio> int main() { int x1, x2, x3, u, h; int n; while (~scanf("%d", &a ...

  2. hdu1024

    #include <cstdio>#include <iostream>const int MAX = 1000005; using namespace std; int nu ...

  3. Java和R齐头并进才是根本

    Java和R齐头并进才是根本  数据分析师的成长之路  http://www.slideshare.net/SanderMak/data-science-with-r-for-java-d

  4. Debug / Inspect WebSocket traffic with Fiddler【转】

    Introduction I have recently written a project using SignalR, which supports HTML 5 WebSocket.  Howe ...

  5. 大数据时代之hadoop(二):hadoop脚本解析

    “兵马未动,粮草先行”,要想深入的了解hadoop,我觉得启动或停止hadoop的脚本是必须要先了解的.说到底,hadoop就是一个分布式存储和计算框架,但是这个分布式环境是如何启动,管理的呢,我就带 ...

  6. POJ 2305 Basic remains(进制转换)

    题目链接:http://poj.org/problem?id=2305 ime Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5326 ...

  7. 8、Spring+Struts2+MyBaits(Spring注解+jdbc属性文件+log4j属性文件)

    一.注解理论 使用注解来构造IoC容器 用注解来向Spring容器注册Bean.需要在applicationContext.xml中注册<context:component-scan base- ...

  8. IOS 中会发生crash的操作

    对字典和数组进行下列操作时会产生crash: 对于字典来说: 查询时,key=nil 或者 key=null 时都能正常运行 插入时,,key=nil 或者 key=null 都会crash 对于数组 ...

  9. ATL opengl

    #include <atlbase.h> #include <atlwin.h> #include <gl/glew.h> #include <gl/GL.h ...

  10. MySQL Replicationation基础

    摘要 一.MySQL Replication 介绍MySQL Replication的基本概念,摘自于Mysql官网 二.Replication Configuration 2.1 Basic Ste ...