题意:一杯水有n的容量,问有多少种方法可以喝完。
析:找规律,找出前几个就发现规律了,就是2的多少次幂。
代码如下:
#include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #include <algorithm> #include <vector> #include <map> using namespace std ; typedef long long LL; typedef pair<int, int> P; const int INF = 0x3f3f3f3f; const double inf = 0x3f3f3f3f3f3f3f; const double eps = 1e-8; const int maxn = 1000 + 5; const int dr[] = {0, 0, -1, 1}; const int dc[] = {-1, 1, 0, 0}; int n, m; struct node{ string s; int id; bool operator < (const node &p) const{ return p.id < id; } }; vector<node> v; int main(){ int T; cin >> T; while(T--){ scanf("%d", &n); printf("1"); for(int i = 1; i < n; ++i) printf("0"); printf("\n"); } return 0; }
时间: 2024-10-12 21:29:19