T1

经过一波大力推式子,发现答案是 \(\frac{n^{2}-1}{9}\) 。

式子回头再补,可能会

Code
#include<cstdio>
#define re register
#define int long long
namespace OMA
{
int t,n;
const int p = 998244353;
inline int read()
{
int s=0,w=1; char ch=getchar();
while(ch<'0'||ch>'9'){ if(ch=='-')w=-1; ch=getchar(); }
while(ch>='0'&&ch<='9'){ s=s*10+ch-'0'; ch=getchar(); }
return s*w;
}
inline int quickpow(int a,int b)
{
int ans = 1;
while(b)
{
if(b&1)
{ ans = ans*a%p; }
a = a*a%p;
b >>= 1;
}
return ans;
}
signed main()
{
t = read();
int inv = quickpow(3,p-2);
while(t--)
{
int n = read()%p,ans = 0;
/*for(re int i=1; i<=n; i++)
{
(ans += i*(i-1)%p*inv%p) %= p;
}*/
printf("%lld\n",(n%p*n%p-1)%p*quickpow(9,p-2)%p);
}
return 0;
}
}
signed main()
{ return OMA::main(); }

T2

考场想到了之前的noip14T3,当时xin用的vector 骗分...所以,我也....

好吧,是要加俩剪枝的,

  • 当前枚举长度超过原串,直接break,换集合中的下一个串去接,
  • 如果当前接出来的串对答案无贡献,那也break,因为在一个没出现过的串上加字符,怎么加也不会再产生贡献。不加第二个只能拿20pts

用了个vector和map。

我也不知道为什么我要这么认真的讲暴力,大概因为只会写暴力吧QAQ

40pts
#include<map>
#include<vector>
#include<cstdio>
#include<cstring>
#define MAX 10010
#define re register
namespace OMA
{
int n,len[MAX];
long long ans;
char s[MAX],ch[MAX][MAX];
std::map<std::vector<char>,int>vis;
signed main()
{
//freopen("my.out","w",stdout);
scanf("%s%d",s+1,&n);
len[0] = strlen(s+1);
//printf("\n");
for(re int i=1; i<=len[0]; i++)
{
for(re int j=i+1; j<=len[0]; j++)
{
std::vector<char>str;
for(re int k=i; k<=j; k++)
{ str.push_back(s[k]); }
vis[str]++;
//for(re int k=0; k<str.size(); k++)
//{ printf("%c",str[k]); }
//printf("\n");
//printf("%d\n",vis[str]);
}
}
for(re int i=1; i<=n; i++)
{ scanf("%s",ch[i]+1); len[i] = strlen(ch[i]+1); }
for(re int i=1; i<=n; i++)
{
for(re int j=len[i]; j>=1; j--)
{
for(re int k=1; k<=n; k++)
{
for(re int l=1; l<=len[k]; l++)
{
if(l+len[i]-j+1>len[0])
{ break ; }
std::vector<char>str;
for(re int x=j; x<=len[i]; x++)
{ str.push_back(ch[i][x]); }
for(re int x=1; x<=l; x++)
{ str.push_back(ch[k][x]); }
if(!vis[str])
{ break ; }
//printf("back:%d front:%d: ",i,k);
//for(re int x=0; x<str.size(); x++)
//{ printf("%c",str[x]); }
//if(vis[str])
//{ printf(" true %d",vis[str]); }
//printf("\n");
ans += vis[str];
}
}
}
}
printf("%lld\n",ans);
return 0;
}
}
signed main()
{ return OMA::main(); }

正解还没改出来,所以先咕了。

T3

考场上推出了\(k=2\),但没想到也是\(k>5\) 的时候,加上当时脑抽,一心去推\(k=3\)的, 式子没推出来,其他式子还码错了。不过竟然能过样例

正解就是推式子。

原式子不想写了,直接看代码。

80pts
#include<cstdio>
#define MAX 300030
#define re register
#define int long long
namespace OMA
{
int c[MAX],inv[MAX];
int t,n[MAX],m[MAX],k[MAX];
const int p = 3e5+7;
inline int read()
{
int s=0,w=1; char ch=getchar();
while(ch<'0'||ch>'9'){ if(ch=='-')w=-1; ch=getchar(); }
while(ch>='0'&&ch<='9'){ s=s*10+ch-'0'; ch=getchar(); }
return s*w;
}
inline int quickpow(int a,int b)
{
int ans = 1;
while(b)
{
if(b&1)
{ ans = ans*a%p; }
a = a*a%p;
b >>= 1;
}
return ans;
}
inline int min(int a,int b)
{ return a<b?a:b; }
inline int max(int a,int b)
{ return a>b?a:b; }
inline int abs(int a)
{ return a>=0?a:0; }
inline int C(int n,int m)
{ return m>n?0:c[n]*inv[n-m]%p*inv[m]%p; }
inline int lucas(int n,int m)
{ return !m?1:C(n%p,m%p)*lucas(n/p,m/p)%p; }
int ans;
inline int sum1(int n)
{ return (n%p*(n%p+1))>>1; }
inline int sum2(int n)
{ return (n%p-1)*n%p*(n%p+1)%p; }
#define n n[i]
#define m m[i]
#define k k[i]
inline void task0(int i)
{
ans = 0;
for(re int a=1; a<=n; a++)
{
for(re int b=1; b<=m; b++)
{ (ans += lucas(min(a,b)-1,k-1)) %= p; }
}
ans = ans*2%p;
(ans += lucas(n,k)*m%p+lucas(m,k)*n%p) %= p;
} // OK
inline void task1(int i)
{ ans = (n%p)*(m%p)%p; } // OK
inline void task3(int i)
{
for(re int len=2; len<=m; len++)
{ (ans += 4*(n-len+1)%p*(m-len+1)%p) %= p; }
for(re int len=1; len<=n/2; len++)
{ (ans += 2*abs(n-len)%p*abs(m-len-len)%p+2*abs(m-len)%p*abs(n-len-len)%p) %= p; }
}
inline void task4(int i)
{
for(re int len=2; len<=m; len++)
{ (ans += (n-len+1)%p*(m-len+1)%p)%= p ; }
for(re int len=3; len<=m; len+=2)
{ (ans += 4*(n-len+1)%p*(m-len+1)%p) %= p; }
for(re int len=1; len<=m/2; len++)
{ (ans += abs(n-len-len)%p*abs(m-len-len)%p) %= p; }
for(re int len=1; len<=n/2; len++)
{ (ans += 2*abs(n-len)%p*abs(m-len-len)%p+2*abs(m-len)%p*abs(n-len-len)%p) %= p; }
}
inline void task5(int i)
{
for(re int len=3; len<=m; len+=2)
{ (ans += (n-len+1)%p*(m-len+1)%p) %= p; }
for(re int len=1; len<=m/2; len++)
{ (ans += abs(n-len-len)%p*abs(m-len-len)%p) %= p; }
}
inline void swap(int &a,int &b)
{ int t=a; a=b; b=t; }
signed main()
{
t = read();
for(re int i=1; i<=t; i++)
{ n = read(),m = read(),k = read(); }
int top = p-1;
c[0] = inv[0] = 1;
for(re int i=1; i<=top; i++)
{ c[i] = i*c[i-1]%p; }
inv[top] = quickpow(c[top],p-2);
for(re int i=top-1; i; i--)
{ inv[i] = (i+1)*inv[i+1]%p; }
for(re int i=1; i<=t; i++)
{
if(n<m)
{ swap(n,m); }
task0(i);
if(k==1)
{ task1(i); }
else if(k==2)
{ ; }
else if(k==3)
{ task3(i); }
else if(k==4)
{ task4(i); }
else if(k==5)
{ task5(i); }
else
{ ; }
printf("%lld\n",ans);
}
return 0;
}
}
signed main()
{ return OMA::main(); }

然而这过不了后两个点,会T,考虑将式子中的循环拆开。

目前正在化\(k=5\),等回头化出来,再补上吧。

noip25的更多相关文章

随机推荐

  1. Oracle如何以逗号分隔的字符串拆分为多行数据

    近期在工作中遇到某表某字段是可扩展数据内容,信息以逗号分隔生成的,现需求要根据此字段数据在其它表查询相关的内容展现出来,第一想法是切割数据,以逗号作为切割符,以下为总结的实现方法,以供大家参考.指教. ...

  2. Linux | 压缩与解压详解

    tar tar 命令用于对文件进行打包压缩或解压,格式: tar [选项][文件] tar命令的参数及其作用 参数 作用 -c 创建压缩文件 -x 解开压缩文件 -t 查看压缩包内有哪些文件 -z 用 ...

  3. kong插件Prometheus+grafana图形化展示

    目录 1. 准备工作 3. 为kong添加 prometheus插件 4. 打开kong的metrics支持 4. 配置prometheus.yml添加kong提供的数据信息 5. 在 Grafana ...

  4. c语言字符串占据字节数

    # include <stdio.h> //字符串占据的字节数 /* 不能将一个字符串常量赋给一个字符变量 为什么不能将一个字符串常量赋给一个字符变量?可以从两个方面作出解释: 前面讲过, ...

  5. Jupyter使用快捷键

    命令行模式(按 Esc 生效) F: 查找并且替换 Ctrl-Shift-F: 打开命令配置 Ctrl-Shift-P: 打开命令配置 Enter: 进入编辑模式 P: 打开命令配置 Shift-En ...

  6. Java多线程(上)

    Java多线程 程序.进程和线程 一.程序 程序是存储在磁盘上, 包含可执行机器指令和数据的静态实体. 即进程或者任务是处于活动状态的计算机程序. 二.进程 进程是资源(CPU.内存等)分配的基本单位 ...

  7. 一次搞懂JavaScript对象

    索引 目录 索引 1. 对象与类 2.对象使用 2.1 语法 2.2 属性 3.对象特性 4.对象的创建 4.1 字面量 4.2 工厂函数 4.3 构造函数 4.4 class类 4.5 对象与单例模 ...

  8. java String转List<Device>集合

    // 从Redis中获得正常设备的数量 String success = redisService.get(RedisKey.CULTIVATION_RECORD_SUCCESS); //建立一个li ...

  9. python基础问题

    包安装相关问:如何安装Python三方包?在命令行如何检查一个包是否已安装?答:安装用pip install 卸载用 pip uninstall 直接import 这个包问:环境变量PATH的作用是什 ...

  10. bs4爬取笔趣阁小说

    参考链接:https://www.cnblogs.com/wt714/p/11963497.html 模块:requests,bs4,queue,sys,time 步骤:给出URL--> 访问U ...