C
Attendance problem, prefix and computing, all the negative items added to a set, if the current prefix and less than 0, from small to large pop-up set in negative terms, and the pop-up items added back to the prefix and.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll input(){
ll x=0,f=0;char ch=getchar();
while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return f? -x:x;
}
#define PII pair<ll,int>
#define fr first
#define sc second
#define mp make_pair
const int N=2e5+7;
set<PII> s;
ll a[N],sum;
char Ans[N][20];
int main(){
int n=input()+input();
for(int i=1;i<=n;i++){
a[i]=input();
sum+=a[i];
if(a[i]>0) strcpy(Ans[i],"resupplied");
else{
strcpy(Ans[i],"approved");
s.insert(mp(-a[i],i));
}
while(sum<0){
auto it=--s.end();
sum+=it->fr;
strcpy(Ans[it->sc],"declined");
s.erase(it);
}
}
for(int i=1;i<=n;i++){
printf("%s\n",Ans[i]);
}
}
E
And that the need to use pentagonal number theorem:
\[\prod_{n=1}^\infty(1-x^n)=\sum_{k=-\infty}^\infty(-1)^kx^{\frac{k(3k-1)}{2}}=\sum_{k=0}^\infty(-1)^kx^{\frac{k(3k\pm1)}{2}}\\ (1-x)(1-x^2)(1-x^3)\cdots=1-x-x^2+x^5+x^7-x^{12}-x^{15}+x^{22}+x^{26}\cdots \]
Coefficient known symbol relationships observed for the \ (+ - ++ - ++ - \) discussed before removing the three can be classified. For example, a paragraph is \ (+ X ^ A + X ^ BX ^ CX ^ D \) , then the \ (A \) position \ (. 1 \) , \ ([A +. 1, B] \) position \ (0 \) , \ ([B +. 1, C-. 1] \) position \ (. 9 \) , \ (C \) position \ (. 8 \) , \ ([C +. 1, D] \) location is \ (9 \) . Then by half a bit like a judge in that position.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll input(){
ll x=0,f=0;char ch=getchar();
while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return f? -x:x;
}
ll f(ll k){return k*(k*3+1)/2;}
int main(){
int T=input();
while(T--){
ll n=input();
ll l=0,r=1e9,k;
while(l<=r){
ll mid=(l+r)>>1;
if(f(mid)<n) k=mid,l=mid+1;
else r=mid-1;
}
ll nr=f(k++);
int Ans=0;
if(k&1){
if(n==nr+2*k-1) Ans=8;
else if(n<=nr+3*k-1) Ans=9;
else Ans=0;
}else{
if(n==nr+2*k-1) Ans=1;
else if(n<=nr+3*k-1) Ans=0;
else Ans=9;
}
printf("%d%c",Ans,T==0?'\n':' ');
}
}