qdu Mathematics and Geometry(思维题)
来源:互联网 发布:人工智能理论 编辑:程序博客网 时间:2024/05/16 11:29
给你一个n,求方程 2x + y + 2z = n 解的个数,其中x, y, z, n 都是非负整数
第一行一个整数T(T<=1000),表示测试数据组数,接着T行,每行一个整数n(n<=1000000)
每组数据输出一行Case #x: ans 其中x表示样例组数,ans表示解的个数
复制
3123
Case #1: 1Case #2: 3Case #3: 3
#include <iostream>#include <cstdio>using namespace std;int main(){int T, n, cnt = 0;long long ans;cin >> T;while(T--){ans = 0;cin >> n;for(int y = 0; y <= n; y++){if((n - y)%2 == 0){ans += ((n - y)/2 + 1);}}printf("Case #%d: %lld\n", ++cnt, ans);}return 0;}
2 0
- qdu Mathematics and Geometry(思维题)
- 1869: Mathematics and Geometry
- ZZULI 1869: Mathematics and Geometry【数学】
- QDU BelamiYao的一道简单签到题(思维)
- Codeforces 689E Mike and Geometry Problem 思维
- A. Vladik and Courtesy(思维题)
- QDU Julyc和CerberuX去吃饭后传(贪心、思维)
- Mathematics
- Mathematics
- Mathematics
- Codeforces 689E Mike and Geometry Problem(组合数学)
- CF689E:Mike and Geometry Problem(组合数)
- Discrete Mathematics and Its applications - 离散数学及其应用 读书笔记 ( 二 )
- Discrete Mathematics and Its applications - 离散数学及其应用 读书笔记 ( 一 )
- 《 Discrete Mathematics and its Applications 》 离散数学及其应用 读书笔记 ( 三 )
- 求最大值(qduoj)QDU创新实验室第二次月赛B题
- QDU第二次月赛 简单题
- qdu 校赛 模拟的好题
- 教你步步为营掌握自定义 View
- ios开发中最简单的tableview使用一
- Head First Design Patterns 阅读笔记之三: Decorator Pattern
- Java RESTful框架的性能比较
- js动态生成html,获取点击的监控事件写法
- qdu Mathematics and Geometry(思维题)
- VMware 12 安装 Mac OS X 10.10
- 图数据库Titan安装与部署
- [382]Linked List Random Node
- Android闹钟设置的解决方案
- 千里之行,始于足下。从今天开始记录android移动开发的点点滴滴
- 更加简洁且通用的ViewHolder写法
- 【机房】机房收费系统总览
- 16位汇编 int 10h和int 21h 显示字符串实例