A
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
cin>>n;
int m=0;
int i=0;
int pos=0;
while(m<=n)
{
m+=pow(2,i);
i++;
pos++;
}
cout<<pos;
}
B
模拟
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int sum=0;
int cnt=1;
int main()
{
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++)
{
int a;
cin>>a;
sum+=a;
while(sum>k)
{
sum=a;
cnt++;
}
}
cout<<cnt;
}
标签:std,int,sum,++,cin,ABC353,include
From: https://blog.csdn.net/2301_79203206/article/details/139480624