http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27938#problem/E

题目大意:Given, n, count the number of solutions to the equation x+2y+2z=n, where x,y,z,n are non negative integers.
解题思路:只对一个枚举由此推算出另外两个的种类,千万不要都枚举!!!
#include<iostream>
#include<fstream>
#include<string>
#include<string.h>
using namespace std;
int main(){
for(long long int n;cin>>n;){
long long int y,sum=;
for(y=;y<=n/;y++){
sum+=(n-*y)/+;
}
cout<<sum<<'\n';
}
}

[ACM_数学] Counting Solutions to an Integral Equation (x+2y+2z=n 组合种类)的更多相关文章

  1. [ACM_模拟][ACM_数学] LA 2995 Image Is Everything [由6个视图计算立方体最大体积]

    Description   Your new company is building a robot that can hold small lightweight objects. The robo ...

  2. [ACM_数学] LA 3708 Graveyard [墓地雕塑 圈上新加点 找规律]

    Description   Programming contests became so popular in the year 2397 that the governor of New Earck ...

  3. [ACM_数学] Taxi Fare [新旧出租车费差 水 分段函数]

    Description Last September, Hangzhou raised the taxi fares. The original flag-down fare in Hangzhou ...

  4. [ACM_数学] Fibonacci Nim(另类取石子,2-4组合游戏)

    游戏规则: 有一堆个数为n的石子,游戏双方轮流取石子,满足: 1)先手不能在第一次把所有的石子取完: 2)之后每次可以取的石子数介于1到对手刚取的石子数的2倍之间(包含1和对手刚取的石子数的2倍). ...

  5. [ACM_数学] 大菲波数 (hdu oj 1715 ,java 大数)

    大菲波数 Problem Description Fibonacci数列,定义如下:f(1)=f(2)=1f(n)=f(n-1)+f(n-2) n>=3.计算第n项Fibonacci数值.   ...

  6. [GodLove]Wine93 Tarining Round #10

    比赛链接: http://www.bnuoj.com/v3/contest_show.php?cid=4159 题目来源: lrj训练指南---几何算法 Flag ID Title   A Board ...

  7. (light oj 1306) Solutions to an Equation 扩展欧几里得算法

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1306 You have to find the number of solutions ...

  8. [lightoj P1306] Solutions to an Equation

    [lightoj P1306] Solutions to an Equation You have to find the number of solutions of the following e ...

  9. Codeforces Little Dima and Equation 数学题解

    B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input s ...

随机推荐

  1. CRC

    #define POLY 0x1021 /** * Calculating CRC-16 in 'C' * @para addr, start of data * @para num, length ...

  2. Javascript类型

    Javascript 有两中类型:原始类型和对象类型. 原始类型包括:数字,字符串,布尔值,null和undefined.其余的都是对象类型. 原始类型 数字.Javascript采用IEEE754标 ...

  3. SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' 解决办法

    当跑jndi项目时抛出:org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' fo ...

  4. C#的 构造函数 和 方法重载

    构造函数(一本正经的讲构造函数 如果想看不正经的往下翻看方法重载) 方法名称与类名相同,没有返回值类型,连void都没有 用作给类的对象初始化 一个类中可以有多个构造 如果手动添加一个构造,系统不会自 ...

  5. POJ 1696 - Space Ant 凸包的变形

    Technorati Tags: POJ,计算几何,凸包 初学计算几何,引入polygon后的第一个挑战--凸包 此题可用凸包算法做,只要把压入凸包的点从原集合中排除即可,最终形成图形为螺旋线. 关于 ...

  6. 51单片机ALE引脚的控制(摘录)

    ALE/PROG: 当访问外部存储器时,地址锁存允许的输出电平用于锁存地址的地位字节. 在FLASH编程期间,此引脚用于输入编程脉冲. 在平时,ALE端以不变的频率周期输出正脉冲信号,此频率为振荡器频 ...

  7. C#数据库操作

    1.常用的T-Sql语句      查询:SELECT * FROM tb_test WHERE ID='1' AND name='xia'                SELECT * FROM ...

  8. PHP各种缓存

    缓存类型PHP缓存包括PHP变异缓存和PHP数据缓存两种:PHP编译缓存:        PHP数据缓存:    对数据库数据进行缓存    对PHP模板数据缓存 js数据缓存

  9. linux下mysql集群的安装

    3台redhat服务器: SQL节点(mysqld): 192.168.1.77;192.168.1.78 数据节点(ndbd): 192.168.1.77;192.168.1.78 管理节点(ndb ...

  10. rm: Argument list too long

    rm -rf  /testdir/* -bash: /bin/rm: Argument list too long 解决: cd /testdir/; ls | xargs rm -rf