首页 技术 正文
技术 2022年11月23日
0 收藏 842 点赞 4,340 浏览 1525 个字

Time Limit: 15000/8000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)

HDU 4849 – Wow! Such City! InputThere are several test cases. Please process till EOF.
For each test case, there is only one line containing 6 integers
N,M,X0,X1,Y0,Y1.See the description
for more details. OutputFor each test case, output a single line containing a
single integer: the number of minimal category. Sample Input3 10 1 2 3 44 20 2 3 4 5 Sample Output110  Hint:HDU 4849 – Wow! Such City!

怎么说吧,就是一个又臭又长又水的单源最短路径外加算算MOD的题。

 #include<cstdio>
#include<queue>
#include<cstring>
#define MAXN 1003
#define MAXK 1000*1000+1000
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int n,m;
ll x[MAXK],y[MAXK],z[MAXK],c[MAXN][MAXN];
int cate[+];
void calc()
{
int max_k=(n-)*n+(n-);
for(int k=;k<=max_k;k++)
{
if(k>=)
{
x[k]=( + (x[k-] * ) % + (x[k-] * ) % + (x[k-] * x[k-] * ) % ) % ;
y[k]=( + (y[k-] * ) % + (y[k-] * ) % + (y[k-] * y[k-] * ) % ) % ;
}
z[k]=(x[k] * + y[k] ) % + ;
}
//for(int k=0;k<=max_k;k++) printf("x[%d]=%lld \t y[%d]=%lld \t z[%d]=%lld \n",k,x[k],k,y[k],k,z[k]);
for(int i=;i<n;i++)
{
for(int j=;j<n;j++)
{
if(i==j) c[i][j]=;
else c[i][j]=z[(i*n+j)];
//printf("%lld\t",c[i][j]);
}
//printf("\n");
}
}
bool vis[MAXN];
ll d[MAXN];
void spfa()
{
for(int i=;i<n;i++){
vis[i]=;
d[i]=INF;
}
vis[]=;
d[]=;
queue<int> q;
q.push();
while(!q.empty())
{
int u=q.front();q.pop();vis[u]=;
for(int v=;v<n;v++)
{
if(u==v) continue;
ll tmp=d[v];
if(d[v]>d[u]+c[u][v]) d[v]=d[u]+c[u][v];
if(d[v]<tmp && !vis[v]) q.push(v),vis[v]=;
}
}
}
int main()
{
while(scanf("%d %d %lld %lld %lld %lld",&n,&m,&x[],&x[],&y[],&y[])!=EOF)
{
calc();
spfa();
memset(cate,,sizeof(cate));
for(int i=;i<n;i++)
{
//printf("d[%d]=%lld\n",i,d[i]);
cate[(d[i]%m)]++;
}
for(int i=;i<m;i++)
{
if(cate[i]!=)
{
printf("%d\n",i);
break;
}
}
}
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,960
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,484
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,330
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,113
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,745
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,779