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. SQL:将字符串以特定字符分割并返回Table

    split 语法 ALTER FUNCTION [dbo].[F_SPLIT] ( @str VARCHAR(MAX) , ) ) /********************************* ...

  2. VC++ operate excel

    利用VC操作Excel的方法至少有两种 1 .利用ODBC把Excel文件当成数据库文件,来进行读.写.修改等操作,网上有人编写了CSpreadSheet类,提供支持. 2. 利用Automation ...

  3. eclipse javascript验证报错

    项目右键->properties

  4. swift 代码添加image

    let image_ElectricianBtn = UIImage(named: "ElectricianBtn") let vimage_ElectricianBtn = UI ...

  5. spring 下载地址

    http://repo.spring.io/release/org/springframework/spring/

  6. widows下jieba分词的安装

    在切词的时候使用到jieba分词器,安装如下: 切入到结巴包,执行 python setup.py install 安装后,可以直接在代码中引用: import jieba

  7. (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO

    . . . . . 目录 (一) 一起学 Unix 环境高级编程 (APUE) 之 标准IO (二) 一起学 Unix 环境高级编程 (APUE) 之 文件 IO (三) 一起学 Unix 环境高级编 ...

  8. 自定义UIPageControl,可设置任意图片image。

    [self.pageControl setValue:[UIImage imageNamed:@"选中图片名称"] forKeyPath:@"_currentPageIm ...

  9. linux磁盘与文件系统的管理

    本文涉及命令:dumpe2fs.df.du.fdisk.mkfs.mke2fs.fsck.badblocks.mount.umount.e2label.tune2fs.hdparm.parted 概念 ...

  10. flash builder4.7bug

    flash builder4.7项目,swc中的button实例出来有bug,解决办法: 1,把button都改成movieclip. 2,改用swf做资源.