SCU2016-01 K找规律
2016-07-05 22:04
344 查看
Analyse:
很明显这个题是固定的,所以需要预先打表。
Get:
找规律递推就可以了。
很明显这个题是固定的,所以需要预先打表。
Get:
找规律递推就可以了。
/**********************jibancanyang************************** *Author* :jibancanyang *Created Time* : 一 7/ 4 13:59:02 2016 **Problem**: **Code**: ***********************1599664856@qq.com**********************/ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <cmath> #include <cstdlib> #include <ctime> #include <stack> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; #define pr(x) cout << #x << ": " << x << " " #define pl(x) cout << #x << ": " << x << endl; #define pri(a) printf("%d\n",(a)) #define xx first #define yy second #define sa(n) scanf("%d", &(n)) #define sal(n) scanf("%lld", &(n)) #define sai(n) scanf("%I64d", &(n)) #define vep(c) for(decltype((c).begin() ) it = (c).begin(); it != (c).end(); it++) const int mod = int(1e9) + 7, INF = 0x3f3f3f3f; const int maxn = 1e5 + 13; ll dp[maxn * 10]; int main(void) { #ifdef LOCAL freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); #endif int n; dp[3] = 0; for (int i = 4; i <= 1000000 ; i++) { dp[i] = dp[i - 1]; ll k = i - 3; ll t = (k + 1) / 2; dp[i] += k * t + t - t * t; } while (sa(n), n > 2) { printf("%lld\n", dp ); } return 0; }
相关文章推荐
- JDBC的数据库查询
- R 语言语法快速浏览
- ld: 6 duplicate symbols for architecture x86_64 clang: error: linker command的解决方法
- Python学习笔记7:Python字典和集合
- java 冒泡排序算法
- 第十一天打字
- 图算法5之1006
- 双链表基本操作
- Redis学习笔记(三)-数据类型之string类型
- 《深入理解Java集合框架》系列文章
- Unknown Source的出现及解决
- 二叉查找树
- Java的反射解析
- 编程练习--二维数组的查找
- Android中常用布局
- linux 合并文件 cat & paste
- 多线程-死锁Test
- ListView 点击事件
- SWIFT实现图文混排
- 64汇编写程序