HDU-5703-Desert【2016CCPC女生专场】


HDU-5703-Desert



Problem Description

A tourist gets lost in the desert with n liters of water. He drinks positive integer units of water each day.

Write a program to calculate how many different ways the tourist can drink up the water.

Input

The first line contains the number of test cases T(T≤10).

Next T lines contain the number n(1≤n≤1000000) for each test case.

Output

Output consists of T lines.

Each line contains the binary number which represents number of different ways to finish up the water specified in the test case.

Sample Input

1

3

Sample Output

100

题目链接:HDU-5703

题目大意:3可以表示为1 1 1,1 2,2 1,3,4种方法。那么任意输入一个n可以表示为几种方法,结果用二进制表示

题目思路:可以发现,方法数为2^(n-1),但是要用二进制表示,那么输出第一位为1,接下来n-1个0就可以

以下是代码:

//
//  5703.cpp
//  2016-CCPC-GIRL
//
//  Created by pro on 16/7/3.
//  Copyright (c) 2016年 loy. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>
#include<iomanip>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        cout << 1;
        for (int i = 1; i < n; i++) cout << 0;
        cout << endl;
    }
    return 0;
}
时间: 2024-11-10 13:03:17

HDU-5703-Desert【2016CCPC女生专场】的相关文章

hdu 5703 Desert(找规律)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5703 Desert Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 177    Accepted Submission(s): 141 Problem Description A tourist gets lost in the dese

HDU 5703 Desert 水题 找规律

已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这题输出二进制数就行了......那就更简单了,直接输出1,然后后面跟n-1个0就行了╮(╯_╰)╭ 下面AC代码 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>

HDU 5703 Desert (找规律)

题意:一杯水有n的容量,问有多少种方法可以喝完. 析:找规律,找出前几个就发现规律了,就是2的多少次幂. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #incl

HDU-5707-Combine String【2016CCPC女生专场】【DP】

HDU-5707-Combine String Problem Description Given three strings a, b and c, your mission is to check whether c is the combine string of a and b. A string c is said to be the combine string of a and b if and only if c can be broken into two subsequenc

HDU-5706-GirlCat【BFS】【2016CCPC女生专场】

HDU-5706-GirlCat Problem Description As a cute girl, Kotori likes playing Hide and Seek'' with cats particularly. Under the influence of Kotori, many girls and cats are playingHide and Seek" together. Koroti shots a photo. The size of this photo is n

&quot;巴卡斯杯&quot; 中国大学生程序设计竞赛 - 女生专场(重现)解题思路

此文章可以使用目录功能哟↑(点击上方[+]) 经过这么一次女生赛,告诉我们千万不要小瞧女生,不然会死得很惨,orz... 链接→"巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场(重现)  Problem 1001 Solving Order Accept: 0    Submit: 0 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit : 32768/32768 K (Java/Others)  Problem Descri

HDU 6024(中国大学生程序设计竞赛女生专场1002)

这是CCPC女生专场的一道dp题.大佬们都说它简单,我并没有感到它有多简单. 先说一下题意:在一条直线上,有n个教室,现在我要在这些教室里从左到右地建设一些作为糖果屋,每个教室都有自己的坐标xi 和建造糖果屋的费用ci , 如果在这里建造一个糖果屋,那么花费ci ,如果不建造糖果屋,则花费是当前教室的坐标与左边最靠近当前教室的糖果屋坐标之差,问最小花费. 一看这是个求最优解的问题,应该明白这是个dp问题,现在来考虑该问题状态的定义: 当我建设到第i个教室的时候,我有两种选择,建糖果屋或者不建糖果

2017中国大学生程序设计竞赛 - 女生专场(dp)

Building Shops Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 701 Accepted Submission(s): 265 Problem Description HDU's n classrooms are on a line ,which can be considered as a number line. Eac

2017中国大学生程序设计竞赛 - 女生专场 Happy Necklace(递推+矩阵快速幂)

Happy Necklace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1146    Accepted Submission(s): 491 Problem Description Little Q wants to buy a necklace for his girlfriend. Necklaces are single