总结
自闭场
极慢签到
罚坐俩小时,补题补不上。
1001 题意
边长为n-1的立方体中,三边分别平行于三个平面的等边三角形数量是多少。
1001 思路
边长为1时,是8个,这8个等边的边长为根号二。所以边长为2的立方体中应该也有8个边长为二倍根号二的。所以边长为n的立方体中,有8n立方个边长根号2的,8(n-1)立方个边长二倍根号2的,以此类推,其实就是八倍的立方和。立方和公式套一下,注意开局n–,以及取模就好了。
1001 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
//#define double long double
using namespace std;
typedef long long ll;
const int maxn=400505;
const int inf=0x3f3f3f3f;
const int mod=1000000007;
int n,m,k;
int pow_m(int a,int k){
int ans=1;
int tmp=a%mod;
while(k){
if(k&1) ans=ans*tmp%mod;
tmp=tmp*tmp%mod;
k>>=1;
}
return ans%mod;
}
inline int pls(int a,int b){
return (a+b)%mod;
}
inline int mul(int a,int b){
return (a*b)%mod;
}
void solve(){
cin>>n;
n--;
n%=mod;
cout<<mul(2,mul(mul(n,n),mul(n+1,n+1)))<<endl;
}
signed main(){
IOS
#ifndef ONLINE_JUDGE
freopen("IO\\in.txt","r",stdin);
freopen("IO\\out.txt","w",stdout);
#endif
int tn=1;
cin>>tn;
while(tn--){
solve();
}
}
1005 题意
给一个串,生成一个新串,每次插入头部或者尾部,要求结果串字典序最小,问构造方式
1005 思路
显然可以贪心生成这个串。生成了之后呢,我们考虑他的方案数,易推的当目前串完全由同一字符组成,且新的字符还是这个字符,它插头插尾是一样的,所以统计下就可以了。
1005 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
//#define double long double
using namespace std;
typedef long long ll;
const int maxn=400505;
const int inf=0x3f3f3f3f;
const int mod=1000000007;
int n,m,k;
int l,r;
char ans[maxn];
void solve(){
string s;
cin>>n;
cin>>s;
char ch=s[0];
int tot=1;
for(int i=1;i<n;i++){
if(s[i]==ch){
tot*=2;
tot%=mod;
}
else break;
}
/* bool ok=1;
l=200000,r=200002;
ans[l+1]=s[0];
for(int i=1;i<n;i++){
if(s[i]<ans[l+1]){
ans[l]=s[i];
l--;
ok=0;
}
else if(s[i]>ans[l+1]){
ans[r]=s[i];
r++;
ok=0;
}
else{
if(ok){
tot*=2;
tot%=mod;
}
ans[l]=s[i];
l--;
}
} *//*
for(int i=l+1;i<r;i++)
cout<<ans[i];
cout<<endl; */
cout<<tot<<endl;
}
signed main(){
IOS
#ifndef ONLINE_JUDGE
freopen("IO\\in.txt","r",stdin);
freopen("IO\\out.txt","w",stdout);
#endif
int tn=1;
cin>>tn;
while(tn--){
solve();
}
}
1008 题意
n课,m个资料,可以提高某一门课y分,花费x天。还有t天考试,最多挂p门,问最大总分数。
1008 思路
背包套背包。
n课m资料,可以处理出fij代表i课花j天最短时间。于是m个资料就没用了,我们可以通过f数组转移。
再来个gijk表示前i门课,j天,挂k门的最大分数,是一个分组背包,每一组相当于每一门课,只能取一个。
1008 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
//#define double long double
using namespace std;
typedef long long ll;
const int maxn=400505;
const int inf=0x3f3f3f3f;
int n,m,k;
int tt,pp;
map<string,int>mp;
int f[55][505];
int dp[55][505][5];
struct what{
int id,value,cost;
}wh[15005];
bool cmp(what a,what b){
return a.id<b.id;
}
void solve(){
cin>>n;
mp.clear();
memset(dp,0xcf,sizeof dp);
memset(f,0,sizeof f);
for(int i=1;i<=n;i++){
string s;
cin>>s;
mp[s]=i;
}
cin>>m;
for(int i=1;i<=m;i++){
string s;
int v,c;
cin>>s>>v>>c;
wh[i]={mp[s],v,c};
}
cin>>tt>>pp;
wh[m+1].id=-1;
for(int i=1;i<=m;i++){
int p;
for(p=i;p<=m+1&&wh[p].id==wh[i].id;p++);
for(int j=i;j<p;j++){
for(int w=tt;w>=wh[j].cost;w--){
f[wh[j].id][w]=max(f[wh[j].id][w],f[wh[j].id][w-wh[j].cost]+wh[j].value);
f[wh[j].id][w]=min(f[wh[j].id][w],100);
}
}
i=p-1;
}
for(int j=0;j<=tt;j++)
for(int w=0;w<=pp;w++)
dp[0][j][w]=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=tt;j++){
for(int w=0;w<=pp;w++){
for(int t=1;t<=j;t++){
if(f[i][t]>=60)
dp[i][j][w]=max(dp[i][j][w],dp[i-1][j-t][w]+f[i][t]);
else if(w)
dp[i][j][w]=max(dp[i][j][w],dp[i-1][j-t][w-1]+f[i][t]);
}
}
}
}
int ans=-1;
for(int j=1;j<=tt;j++)
for(int w=0;w<=pp;w++)
ans=max(ans,dp[n][j][w]);
cout<<ans<<endl;
}
signed main(){
IOS
#ifndef ONLINE_JUDGE
freopen("IO\\in.txt","r",stdin);
freopen("IO\\out.txt","w",stdout);
#endif
int tn=1;
cin>>tn;
while(tn--){
solve();
}
}
1012 题意
找字符串有没有子串114514
1012 思路
string.find(“114514”);
1012 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
//#define double long double
using namespace std;
typedef long long ll;
const int maxn=400505;
const int inf=0x3f3f3f3f;
int n,m,k;
void solve(){
string s;
cin>>s;
if(s.find("114514")!=-1){
cout<<"AAAAAA"<<endl;
}
else{
cout<<"Abuchulaile"<<endl;
}
}
signed main(){
IOS
#ifndef ONLINE_JUDGE
freopen("IO\\in.txt","r",stdin);
freopen("IO\\out.txt","w",stdout);
#endif
int tn=1;
cin>>tn;
while(tn--){
solve();
}
}
E 题意
E 思路
E 代码
在这里插入代码片