https://nanti.jisuanke.com/t/43388
题意
一共有 m 个队伍(无用数据), n 块蛋糕,对蛋糕进行 t 次操作
每次操作:给定当前队伍的人数 num ,对当前蛋糕数量 n 进行需求:
如果 n>num,num-=n;
否则,把所有的蛋糕切成两半(即n*=2)之后,再次进行需求;
问最终留下的蛋糕快数
简单模拟
代码
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cmath> #include<cstdlib> #include<ctime> #include<deque> #include<iomanip> #include<list> #include<map> #include<queue> #include<set> #include<stack> #include<vector> #include <vector> #include <iterator> #include <utility> #include <sstream> #include <limits> #include <numeric> #include <functional> using namespace std; #define gc getchar() #define mem(a) memset(a,0,sizeof(a)) //#define sort(a,n,int) sort(a,a+n,less<int>()) #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; typedef char ch; typedef double db; const double PI=acos(-1.0); const double eps=1e-6; const ll mod=1e9+7; const int inf=0x3f3f3f3f; const int maxn=1e5+10; const int maxm=100+10; bool compare(int a, int b) { return a < b;//升序 } int main(){ int T = 0; cin >> T; int stu = 0 , bro = 0; int group_num = 0; int group = 0; for(int t = 1;t<=T;t++) { cin >>stu >>bro; cin >>group_num; cout<<"Practice #"<<t<<": "<<stu<<" "<<bro<<endl; for(int i = 0;i<group_num;i++) { cin >>group; while(bro <= group) { bro *=2; } bro -= group; cout<<group<<" "<<bro<<endl; } cout<<endl; } return 0; }
原文地址:https://www.cnblogs.com/SutsuharaYuki/p/12443455.html
时间: 2024-11-07 22:08:40