zoukankan
html css js c++ java
HDU2254 奥运 矩阵应用
//最原始的矩阵应用,不解释 #include "Mat.h" #include <iostream> #include<map> #include<string> using namespace std; map<string, int> M; Mat mat, temp1, temp2; int main() { int n, cnt, k, t1, t2, ans, a1, a2; string p1, p2, v1, v2; mod = 2008; while(cin>>n) { mat.clear(); M.clear(); cnt = 1; while(n--) { cin>>p1>>p2; if(M[p1] == 0) M[p1] = cnt++; if(M[p2] == 0) M[p2] = cnt++; mat.s[M[p1]][M[p2]]++; } mat.sizei = cnt; mat.sizej = cnt; cin>>k; while(k--) { cin>>v1>>v2>>t1>>t2; if(M[v1]==0||M[v2]==0||(t1==0&&t2==0)) { cout<<0<<endl; continue; } if(t1>t2) swap(t1, t2); temp1 = mat;temp2 = mat; temp1.solve(t2);a1 = temp1.s[M[v1]][M[v2]]; if(t1 <= 1) a2 = 0; else { temp2.solve(t1-1); a2 = temp2.s[M[v1]][M[v2]]; } ans = (a1 - a2 + mod ) % mod; cout<<ans<<endl; } } return 0; }
查看全文
相关阅读:
GNU make manual 翻译(四十一)
GNU make manual 翻译(三十五)
GNU make manual 翻译(三十三)
GNU make manual 翻译(三十八)
GNU make manual 翻译(四十二)
GNU make manual 翻译(三十四)
艾瑞咨询:即时通讯面临多种安全威胁 狼人:
世界头号黑客称奥巴马超级加密黑莓手机可被攻破 狼人:
微软悬赏25万美元捉拿Conficker蠕虫作者 狼人:
信息周刊:随意设置电脑密码存在安全隐患 狼人:
原文地址:https://www.cnblogs.com/windmissing/p/2559895.html
最新文章
C# VS2005自定义安装时,提示 install1组件未实例化的解决办法 武胜
PostgreSQL 性能优化
恼人的设计模式
postgresql之checkpoints
sprintf_s与_snprintf与_snprintf_s
磁盘IO性能监控(Linux 和 Windows)
postgres调优
postgres performance
Linux 查看CPU信息、机器型号等硬件信息
连接postgres特别消耗cpu资源而引发的PostgreSQL性能优化考虑 .
热门文章
max_connections / shared_buffers / effective_cache_size
30个优秀旅游网站案例
15个最佳和最新的jQuery图像效果教程
40套免费社交媒体图标
30个真棒的社会化图标集
25个具有灵感的餐厅网站设计案例
GNU make manual 翻译(三十六)
GNU make manual 翻译(四十)
GNU make manual 翻译(三十九)
GNU make manual 翻译(三十七)
Copyright © 2011-2022 走看看