http://newoj.acmclub.cn/problems/2128
大圈圈
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int mod=1e9+7;
const int maxn=1e4;
ll dp[maxn+5];
int main(){
ll n,m,t,k,w,ans=0;
cin>>t;
dp[0]=1;
dp[1]=2;
for(int i=2;i<=maxn;i++)dp[i]=(dp[i-1]+2*(i-1)%mod)%mod;
while(t--){
cin>>n;
cout<<dp[n]<<endl;
}
return 0;
}
http://newoj.acmclub.cn/problems/2134
购物计划
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int inf=1e9;
const int maxn=500;
string a,b,s;
int main(){
ll n,m,t,k,w,ans=0;
cin>>t;
while(t--){
cin>>n;
cout<<n<<endl<<1;
for(int i=1;i<n;i++)cout<<" "<<1;
cout<<endl;
}
return 0;
}
http://newoj.acmclub.cn/problems/2129
秋季特惠
#include<iostream>
#include<string>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int inf=1e9;
const int maxn=500;
string a,b,s;
int main(){
ll n,m,t,k,w,ans=0;
cin>>t;
while(t--){
cin>>k>>n>>w;
ans=(1LL+w)*w/2LL*k-n;
if(ans>0)cout<<ans<<endl;
else cout<<0<<endl;
}
return 0;
}
http://newoj.acmclub.cn/problems/2135
蟹黄堡的配方
#include<iostream>
#include<string>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int inf=1e9;
const int maxn=500;
string a,b,s;
int main(){
int n,m,t;
cin>>t;
while(t--){
cin>>n;
cin>>a>>s;
b.clear();
bool f=true;
for(int i=0;i<n;i++){
if(a[i]!=s[i]&&a[i]<s[i]){
f=false;
break;
}
else b+=s[i];
}
if(f)cout<<b<<endl;
else cout<<-1<<endl;
}
return 0;
}
http://newoj.acmclub.cn/problems/2130
搭积木
这个其实最简单但是。。。。数组的话,请开1e6!!ans开long long
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int inf=1e9;
const int maxn=1e6+100;
ll a[maxn+5];
int main(){
ll n,m,t;
cin>>n;
a[0]=0;
ll ans=0;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]>a[i-1])ans+=(a[i]-a[i-1]);
}
cout<<ans<<endl;
return 0;
}
http://newoj.acmclub.cn/problems/2131
一条数学题
都是骗你的,就是暴力题,而且上界数据小,就是打表判断题
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<string.h>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int inf=1e9;
const int maxn=1e6;
bool vis[maxn+5];
int main(){
ll n,m,t;
while(cin>>n>>m){
mem(vis,0);
for(int i=0;i<=m;i++){
for(int j=0;j<=m;j++){
vis[i*i+j*j]=1;
}
}
bool f=false;
for(int b=1;b<=m*m/(n-1)*2;b++){//b的上界判断(a+(n-1)b=2*m*m=p*p+q*q)
for(int a=0;a<=m*m*2;a++){
bool ff=true;
for(int i=0;i<n;i++){
ll temp=a+b*i;
if(!vis[temp]||temp>2*m*m){///这个判断好重要的呀!判断上界!
ff=false;
break;
}
}
if(ff){
f=true;
cout<<a<<" "<<b<<endl;
}
}
}
if(!f)cout<<"NONE\n";
cout<<endl;
}
return 0;
}
http://newoj.acmclub.cn/problems/2132
找工作
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int inf=1e9;
const int maxn=1e4;
int a[maxn+5];
int dp[maxn+5];
int main(){
ll n,m,t;
cin>>t;
while(t--){
cin>>n;
for(int i=n;i>=0;i--){
cin>>a[i];
}
for(int i=n-1;i>=0;i--){
dp[i]=a[i+1]*(i+1);
}
bool f=false;
vector<int>ans;
for(int i=n-1;i>0;i--){
if(dp[i]==0&&!f)continue;
if(dp[i]!=0&&!f)f=true;
if(f)ans.push_back(dp[i]);
}
ans.push_back(dp[0]);
cout<<ans[0];
for(int i=1;i<ans.size();i++)cout<<" "<<ans[i];
cout<<endl;
}
return 0;
}
http://newoj.acmclub.cn/problems/2133
恶龙与勇者
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
const double eps=1e-9;
const int inf=1e9;
const int maxn=1e4;
int a[maxn+5];
struct node{
ll b,c;
}x[maxn+5];
bool cmp(node a,node b){
if(a.c==b.c)return a.b>b.b;
return a.c<b.c;//能最多,少花
}
int main(){
ll n,m,t;
cin>>t;
while(t--){
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<m;i++)cin>>x[i].b>>x[i].c;
sort(x,x+m,cmp);
ll ans=0;
bool f=true;
for(int i=0;i<n;i++){
ll val=100LL*maxn;
for(int j=0;j<m;j++){
if(x[j].b>=a[i]){
val=min(val,x[j].c);
break;
}
}
if(val<100LL*maxn){
ans+=val;
}
else {
f=false;
break;
}
}
if(f)cout<<ans<<endl;
else cout<<"Kingdom fall\n";
}
return 0;
}