B

代码

#include<iostream>
#include<cmath>
#include<stack>
#include<vector>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
const ll inf =1e17;
#define scn(a) scanf("%d",&a)
#define scd(a) scanf("%lf",&a)
#define scl(a) scanf("%lld",&a)
#define ptf(a) printf("%d\n",a)
#define mes(a,b) memset(a,b,sizeof(a))
#define fon(s,n) for(int i=s;i<=n;i++)
#define range(i,a,b) for(int i=a;i<=b;++i)
#define rerange(i,a,b) for(int i=a;i>=b;--i)
//#define N 100010
//const ll p =998244353;
const int S=20;
ll gcd(ll a,ll b) { return b>0 ? gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll q_pow(ll a,ll b,ll mod)
{
ll ans=1,res=a;
while(b){
if(b&1) ans=ans*res%mod;
res=res*res%mod;
b>>=1;
}
return ans%mod;
}

#define maxn 1000010
bool vis[maxn];
ll prime[maxn],x;
ll cnt[maxn]={0};
void isprime(int n) //埃氏筛
{
for(int i=2;i<=n;i++)
{
if(!vis[i]) prime[x++]=i;
for(int j=2;j*i<=n;j++)
{
vis[i*j]=true;
}
}
}
void count(){
for(int i=2;i<=maxn;i++){
int temp=i;
int re=1;
for(int j=0;j<x&&vis[temp];j++){
while(temp%prime[j]==0&&vis[temp]){
re++;
temp/=prime[j];
}
}
cnt[i]=re;
}
}

const ll mp=1e9+7;
int main()
{
int t,n;
ll c;
isprime(1000005);
count();
scn(t);
while(t--){
scn(n);scl(c);
ll ans;
//if(n==1) ans=c%mp;
//else
ans=q_pow(c,cnt[n],mp);
printf("%lld\n",ans);
}
return 0;
}


C

题意

SS的|S||S|个后缀进行ff操作，求这|S|个操作后的后缀的本质不同的子串个数

代码

#include<bit s/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3e6+10;
char s[maxn], t[maxn], rec[maxn];

struct Trie
{
int O, c[maxn], fa[maxn], tr[maxn][10];
int pos[maxn];

Trie()
{
O = 1;
}
void insert(int k, char ch[], int id)
{
int p = id;
for (int i = 1; ch[i]; ++i)
{
int rec = ch[i] - 'a';
if (!tr[p][rec])tr[p][rec] = ++O, fa[O] = p, c[O] = rec;
p = tr[p][rec];
}
pos[k] = p;
}
}T1;

struct Suffix_Automaton
{
int O, pos[maxn], link[maxn], len[maxn], trans[maxn][10];
queue<int> Q;
Suffix_Automaton()
{
O = 1;
}
int insert(int ch, int last)
{
int x, y, z = ++O, p = last;
len[z] = len[last] + 1;
while (p && !trans[p][ch])trans[p][ch] = z, p = link[p];
if (!p)link[z] = 1;
else {
x = trans[p][ch];
if (len[p] + 1 == len[x])link[z] = x;
else {
y = ++O;
len[y] = len[p] + 1;
for (int i = 0; i < 10; ++i)trans[y][i] = trans[x][i];
while (p && trans[p][ch] == x)trans[p][ch] = y, p = link[p];
}
}
return z;
}

void build()
{
for (int i = 0; i < 10; ++i)if (T1.tr[1][i])Q.push(T1.tr[1][i]);
pos[1] = 1;
while (!Q.empty()) {
int x = Q.front();
Q.pop();
pos[x] = insert(T1.c[x], pos[T1.fa[x]]);
for (int i = 0; i < 10; ++i)if (T1.tr[x][i])Q.push(T1.tr[x][i]);
}
}

void solve()
{
ll ans = 0;
for (int i = 2; i <= O; ++i)ans += len[i] - len[link[i]];
printf("%lld\n", ans);
}
} SAM;

int main()
{
scanf("%s",s+1);
int n=strlen(s+1);
int len=0;int cnt=0;
t[++len]=s[n];
T1.pos[n+1]=1;
T1.insert(n,t,1);
for(int i=n-1;i;i--)
{
cnt=0;
rec[++cnt]=s[i];
int k=i+1;
for(int j=len;j>=1;j--)
{
if(s[i]<=t[j]) break;
if(s[i]>t[j])
{
t[j]=s[i];
rec[++cnt]=s[i];
++k;
}
}
rec[cnt+1]='\0';
T1.insert(i,rec,T1.pos[k]);
t[++len]=s[i];
}
SAM.build();
SAM.solve();
return 0;
}



F

代码

#include<bits/stdc++.h>//自己的
using namespace std;
int main(){
int te;
cin>>te;
while(te--){
int a,b,c,d;
bool f=1;
cin>>a>>b>>c>>d;
int q=min(a,min(b,min(c,d)));
if(q==a){
int x=c*c-a*a;
int xx=(x+b*b-d*d);
if(xx>0) {
puts("AB//CD");
continue;
}
else {
puts("AB//DC");
continue;
}
}
else if(q==b){
int x=d*d-b*b;
int xx=(x+a*a-c*c);
if(xx>0) {
puts("AB//DC");
continue;
}
else {
puts("AB//CD");
continue;
}
}
else if(q==c){
int x=a*a-c*c;
int xx=(x+d*d-b*b);
if(xx>0) {
puts("AB//DC");
continue;
}
else {
puts("AB//CD");
continue;
}
}
else if(q==d){
int x=b*b-d*d;
int xx=(x+c*c-a*a);
if(xx>0) {
puts("AB//CD");
continue;
}
else {
puts("AB//DC");
continue;
}
}
}
return 0;
}


#include<bits/stdc++.h>//大佬的
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int a,b,c,d;
cin>>a>>b>>c>>d;
puts(b+c>a+d?"AB//CD":"AB//DC");
}
return 0;
}



H

代码

#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false),cin.tie(0);
#define ll long long
#define inf 0x3f3f3f3f
const int N=2e5+5;
//set<string>b;
//set<string>::iterator it;
int a[N],vis[N];
void init()
{
int i,j;
for(i=2;i<=N;i++)
{
if(!vis[i])
{
for(j=2*i;j<=N;j+=i)
{
vis[j]=1;
}
}
}
}
int main()
{
IO;
init();
int T,n,i,j,pos,ans;
cin>>T;
while(T--)
{
pos=0;ans=0;
cin>>n;
for(i=1;i<=n;i++) a[i]=0;
for(i=n/2;i>=2;i--)
{
if(!vis[i])
{
pos=i;
for(j=n/i*i;j>i;j-=i)
{
if(a[j]) continue;
if(pos==0) pos=j;
else
{
ans++;
a[j]=pos;
a[pos]=j;
pos=0;
}
}
}
}
cout<<ans<<endl;
for(i=2;i<=n;i++)
{
if(a[i]>i) cout<<i<<" "<<a[i]<<endl;
}
}
return 0;
}



一级目录

代码

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

For the brave

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

08-08 78
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客