分段打表大法好!!!

打表40min,A题1s

https://nanti.jisuanke.com/t/41300

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define mod 998244353
const int maxn=+;
int P[maxn],phi[maxn],cnt=;
bool f[maxn];
void init()
{
phi[]=;
for(int i=;i<maxn;i++){
if(!f[i]){
P[cnt++]=i;
phi[i]=i-;
}
for(int j=;j<cnt;j++){
if(i*P[j]>maxn)break;
f[i*P[j]]=;
if(i%P[j]==){
phi[i*P[j]]=phi[i]*P[j];
break;
}
phi[i*P[j]]=phi[i]*(P[j]-);
}
}
}
int qp(int x,int n)
{
int ans=;
int a=x;
while(n){
if(n&){
ans=(ans*a)%mod;
}
a=(a*a)%mod;
n>>=;
}
return ans;
}
int ans=;
void cal(int n)
{
int i,j;
int b;
for(j=;j<=n;j++)
for(i=;i<=n;i++){ b=qp(,phi[i]*phi[j]);
//else b=B[b];
ans+=(phi[i]*phi[j])%mod*b%mod;
ans%=mod;
}
cout<<ans<<'\n';
}
void cal2(int x,int y)
{
//cout<<x<<' '<<y<<endl;
int b;
for(int i=;i<=y;i++){
int n=i+x;
for(int j=;j<=n;j++){
b=qp(,phi[n]*phi[j]);
//else b=B[b];
if(j!=n){
b=(b*)%mod;
}
ans+=(phi[n]*phi[j])%mod*b%mod;
ans%=mod;
}
}
cout<<ans<<'\n';
}
int Ans[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
};
signed main()
{
int T;
int n;
init();
scanf("%lld",&T);
while(T--){
scanf("%lld",&n);
if(n<){
ans=;
cal(n);
}else if(n<){
int x=(n-)/;
ans=Ans[x];
//cout<<ans<<'\n';
int a=*(n/);
int b=n%;
cal2(a,b);
}else if(n<){
int x=(n-)/+(-)/;
ans=Ans[x];
int a=()*(n/);
int b=n%;
cal2(a,b);
}else{
int x=(n-)/+(-)/+(-)/;
ans=Ans[x];
int a=()*(n/);
int b=n%;
cal2(a,b);
}
}
}
打表代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define mod 998244353
const int maxn=+;
int P[maxn],phi[maxn],cnt=,B[*maxn+];
bool f[maxn];
void init()
{
phi[]=;
for(int i=;i<maxn;i++){
if(!f[i]){
P[cnt++]=i;
phi[i]=i-;
}
for(int j=;j<cnt;j++){
if(i*P[j]>maxn)break;
f[i*P[j]]=;
if(i%P[j]==){
phi[i*P[j]]=phi[i]*P[j];
break;
}
phi[i*P[j]]=phi[i]*(P[j]-);
}
}
B[]=;
for(int i=;i<=*maxn;i++){
B[i]=(B[i-]*)%mod;
}
}
int qp(int x,int n)
{
int ans=;
int a=x;
while(n){
if(n&){
ans=(ans*a)%mod;
}
a=(a*a)%mod;
n>>=;
}
return ans;
}
int ans=;
void cal(int n)
{
int i,j=n;
int b;
for(i=;i<=n;i++){
b=phi[i]*phi[j];
if(b>=*maxn){
b=qp(B[phi[i]],phi[j]);
}
else b=B[b];
if(i!=n)
b=(*b)%mod;
ans+=(phi[i]*phi[j])%mod*b%mod;
ans%=mod;
}
cout<<ans<<',';
}
signed main()
{
//cout<<sizeof(Ans)/sizeof(Ans[0]);
init();
freopen("a.txt","w",stdout);
for(int i=;i<=;i++){
cal(i);
} }

南京网络赛C的更多相关文章

  1. HDU 4751 Divide Groups (2013南京网络赛1004题,判断二分图)

    Divide Groups Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  2. HDU 4750 Count The Pairs (2013南京网络赛1003题,并查集)

    Count The Pairs Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others ...

  3. HDU 4758 Walk Through Squares (2013南京网络赛1011题,AC自动机+DP)

    Walk Through Squares Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Oth ...

  4. 2018ICPC南京网络赛

    2018ICPC南京网络赛 A. An Olympian Math Problem 题目描述:求\(\sum_{i=1}^{n} i\times i! \%n\) solution \[(n-1) \ ...

  5. 2019ICPC南京网络赛A题 The beautiful values of the palace(三维偏序)

    2019ICPC南京网络赛A题 The beautiful values of the palace https://nanti.jisuanke.com/t/41298 Here is a squa ...

  6. 2019 南京网络赛A

    南京网络赛自闭现场 https://nanti.jisuanke.com/t/41298 二维偏序经典题型 二维前缀和!!! #include<bits/stdc++.h> using n ...

  7. 计蒜客 2018南京网络赛 I Skr ( 回文树 )

    题目链接 题意 : 给出一个由数字组成的字符串.然后要你找出其所有本质不同的回文子串.然后将这些回文子串转化为整数后相加.问你最后的结果是多少.答案模 1e9+7 分析 : 应该可以算是回文树挺裸的题 ...

  8. 南京网络赛B-The writing on the wall

    30.43% 2000ms 262144K Feeling hungry, a cute hamster decides to order some take-away food (like frie ...

  9. The writing on the wall 南京网络赛2018B题

    样例输入复制 2 3 3 0 3 3 1 2 2 样例输出复制 Case #1: 36 Case #2: 20 题目来源 ACM-ICPC 2018 南京赛区网络预赛 题意: 就是求图中去掉涂黑的方格 ...

  10. 南京网络赛G-Lpl and Energy【线段树】

    During tea-drinking, princess, amongst other things, asked why has such a good-natured and cute Drag ...

随机推荐

  1. 在 IntelliJ IDEA 中使用 Git,太方便了!

    git是目前流行的分布式版本管理系统.它拥有两套版本库,本地库和远程库,在不进行合并和删除之类的操作时这两套版本库互不影响.也 因此其近乎所有的操作都是本地执行,所以在断网的情况下任然可以提交代码,切 ...

  2. BZOJ 1257 余数之和 题解

    题面 这道题是一道整除分块的模板题: 首先,知道分块的人应该知道,n/i最多有2*sqrt(n)种数,但这和余数有什么关系呢? 注意,只要n/i的值和n/(i+d)的值一样,那么n%i到n%(i+d) ...

  3. python,pycharm环境安装

    1.1 python3安装四部曲 第一步下载 地址 https://www.python.org/downloads/windows/ 第二步安装 1. 第三步 配置坏境变量 第四步 测试是否完成安装 ...

  4. 在docker容器下利用数据卷实现在删除了mysql容器或者镜像的情况下恢复数据

    当把mysql容器销毁,在新建一个容器,进行之前的数据恢复. 因为之前建立了数据卷,那么现在就可以利用这个数据卷进行数据恢复. 使用docker volume create volume_name命令 ...

  5. jqery实现10X10的表格,双击消失

    <script type="text/javascript"> $(document).ready(function(){ //循环拼接html s="&qu ...

  6. vue项目进行时,script标签中,methods事件中函数使用的async/await

    用 async/await 来处理异步 await关键字只能放到async函数里面,通过await得到就是Promise返回的内容:当然也能通过then()去获取,若通过then()获取了则就无Pro ...

  7. Smoke Testing

    [Smoke Testing 释义] Smoke Testing 的概念最早源于制造业,用于测试管道.测试时,用鼓风机往管道里灌烟,看管壁外面是否有烟冒出来,以便检验管道是否有缝隙.这一测试显然比较初 ...

  8. 常用Java中response.setContentType参数

    image/bmp BMP image/png PNG image/gif GIF image/jpeg JPEG image/tiff TIFF image/x-dcx DCX image/x-pc ...

  9. 初探css-18 尺寸

    CSS 尺寸 (Dimension) CSS 尺寸 (Dimension) 属性允许你控制元素的高度和宽度.同样,它允许你增加行间距. 更多实例 这个例子演示了如何设置不同元素的高度. <sty ...

  10. INSERT - 在表中创建新行

    SYNOPSIS INSERT INTO table [ ( column [, ...] ) ] { DEFAULT VALUES | VALUES ( { expression | DEFAULT ...