当前位置:网站首页>2021GDCPC Guangdong University Student Programming Competition H.History
2021GDCPC Guangdong University Student Programming Competition H.History
2022-07-30 22:56:00 【_Kiwi_Berry_】
题意:
给定一个由n个点,m条边组成的图,每走一步,All edge weights are transformed according to the following formula
求1到n的最短路
思路:
If it is transformed into different each time,namoThis question doesn't feel feasible,But it was found after several consecutive substitutions,This is a period of4的循环,So it can be done with a layered graph
We can start by building a four-layer map,It can also exist side by sidedijFind the distance between different layers within the function,Here I use the second method
Code:
#include <bits/stdc++.h>
// #define debug freopen("_in.txt", "r", stdin);
#define debug freopen("_in.txt", "r", stdin), freopen("_out.txt", "w", stdout);
typedef long long ll;
typedef unsigned long long ull;
typedef struct Node *bintree;
using namespace std;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll maxn = 1e7 + 10;
const ll maxm = 2e6 + 10;
const ll mod = 998244353;
const double pi = acos(-1);
const double eps = 1e-8;
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1 | 1
ll T, n, m, q, d, kase = 0;
priority_queue<pair<ll, ll>> que;
ll arr[100];
ll dp[3][maxn];
void solve()
{
scanf("%lld", &n);
printf("%lld\n",(dp[0][n]+dp[1][n])%mod);
}
signed main()
{
// debug;
scanf("%lld", &T);
// T = 1;
arr[1] = arr[2] = 1;
for (ll i = 2; i <= 50; i++)
{
arr[i] = arr[i - 1] + arr[i - 2];
}
dp[0][0] = 1;
dp[0][1] = 1;
dp[1][1] = 1;
ll now = 0;
for (ll i = 2; i <= 1e7; i++)
{
if (i >= arr[now])
{
while (i >= arr[now])
{
now++;
}
now--;
}
ll v1=arr[now],v2=arr[now-1];
dp[0][i]=(dp[0][i-v1]+dp[1][i-v1])*v1;
dp[0][i]%=mod;
if(i-v2<v2)
{
dp[1][i]=(dp[0][i-v2]+dp[1][i-v2])*v2;
}
else
{
dp[1][i]=(dp[1][i-v2])*v2;
}
dp[1][i]%=mod;
}
while (T--)
{
solve();
}
}
边栏推荐
猜你喜欢
随机推荐
PS Basic Learning (1)
When Navicat connects to MySQL, it pops up: 1045: Access denied for user 'root'@'localhost'
DFS题单以及模板汇总
MySQL联合查询(多表查询)
ZZULIOJ:1119: sequence order
VS2017 compile Tars test project
抽象类和接口(学习笔记)
Go语学习笔记 - gorm使用 - 事务操作 Web框架Gin(十一)
通过社交媒体建立个人IP的 5 种行之有效的策略
[MySQL] Related operations on databases and tables in MySQL
二进制序列
2021GDCPC广东省大学生程序设计竞赛 H.History
ZZULIOJ: 1120: the most value to exchange
ML之shap:基于FIFA 2018 Statistics(2018年俄罗斯世界杯足球赛)球队比赛之星分类预测数据集利用RF随机森林+计算SHAP值单样本力图/依赖关系贡献图可视化实现可解释性之攻略
Apache Doris series: detailed steps for installation and deployment
Py之pdpbox:pdpbox的简介、安装、案例应用之详细攻略
HF2022-EzPHP reproduction
电脑快捷方式图标变白解决方案
ZZULIOJ:1119: 数列有序
Gxlcms有声小说系统/小说听书系统源码