1.数学老师的报复

#include<iostream>
#include<cstdio>
using namespace std;
int cnt;
short int f[];
long long a,b,n;
long long qread(){
long long i=,j=;
char ch=getchar();
while(ch<''||ch>''){if(ch=='-')j=-;ch=getchar();}
while(ch<=''&&ch>='')i=i*+ch-'',ch=getchar();
return i*j;
}
int main(){
freopen("attack.in","r",stdin);freopen("attack.out","w",stdout);
// freopen("Cola.in","r",stdin);
a=qread();b=qread();n=qread();
cnt=;f[]=;f[]=;
while(){
cnt++;
f[cnt]=(a*f[cnt-]+b*f[cnt-])%;
if(f[cnt]==&&f[cnt-]==)break;
if(cnt==n)break;
}
if(n<=cnt){cout<<f[n];return ;}
cnt-=;
long long ans=n%cnt;
if(ans==)ans=cnt;
ans=f[ans];
cout<<ans;
}

95分 找循环节

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,aa,bb;
struct matrix{
ll a[][];
matrix(){memset(a,,sizeof(a));}
matrix(ll b[][]) {for(int i=;i<;i++)for(int j=;j<;j++)a[i][j]=b[i][j];}
matrix operator * (matrix b)
{
matrix ans;
for(int i=;i<;i++)
for(int j=;j<;j++)
for(int k=;k<;k++)
ans.a[i][j]=(ans.a[i][j]+a[i][k]*b.a[k][j])%;
ans.a[][]%=;
return ans;
}
}S,T; inline ll read()
{
ll x=,f=;char c=getchar();
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} int main()
{
freopen("attack.in","r",stdin);
freopen("attack.out","w",stdout);
while(scanf("%lld%lld%lld",&aa,&bb,&n)!=EOF)
{
n-=;
if(n==-) {printf("");return ;}
ll temp[][]={{aa,},{bb,}}; T=temp;
ll temp2[][]={{,},{,}}; S=temp2;
while(n)
{
if(n&) S=S*T;
T=T*T;
n>>=;
}
S.a[][]%=;
printf("%lld",S.a[][]);
}
return ;
}

100分 矩阵快速幂

2.物理和生物老师的战争

#include<iostream>
#include<cstdio>
using namespace std;
int T,n,m;
double ans;
int main(){
freopen("fseq.in","r",stdin);freopen("fseq.out","w",stdout);
// freopen("Cola.txt","r",stdin);
scanf("%d",&T);
while(T--){
ans=;
scanf("%d%d",&n,&m);
if(n<m){puts("0.000000");continue;}
double d=1.0/(n+1.0);
printf("%.6lf\n",1.0-m*d);
}
}

100分 打表找规律

3.化学竞赛的大奖

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define maxn 20010
#ifdef WIN32
#define PLL "%I64d"
#else
#define PLL "%lld"
#endif
using namespace std;
int n,m,num,head[maxn],Num,Head[maxn];
int dfn[maxn],low[maxn],cnt,belong[maxn],gnum,st[maxn],top;
long long w[maxn];
bool in[maxn];
vector<int>g[maxn];
int fa[maxn][],dis[maxn][],dep[maxn];
struct node{int to,pre,v;}e[],E[];
void Insert(int from,int to,int v){e[++num].to=to;e[num].v=v;e[num].pre=head[from];head[from]=num;}
void Insert2(int from,int to,int v){E[++Num].to=to;E[Num].v=v;E[Num].pre=Head[from];Head[from]=Num;}
void Tarjan(int u,int father){
cnt++;
dfn[u]=low[u]=cnt;st[++top]=u;in[u]=;
for(int i=head[u];i;i=e[i].pre){
int v=e[i].to;
if(v==father)continue;
if(!dfn[v]){
Tarjan(v,u);
low[u]=min(low[u],low[v]);
}
else if(in[v])low[u]=min(low[u],dfn[v]);
}
if(dfn[u]==low[u]){
gnum++;
while(st[top]!=u){
int x=st[top];top--;
in[x]=;
belong[x]=gnum;
g[gnum].push_back(x);
}
in[u]=;
belong[u]=gnum;
g[gnum].push_back(u);
top--;
}
}
void dfs(int now,int father){
dep[now]=dep[father]+;
fa[now][]=father;
for(int i=Head[now];i;i=E[i].pre){
int to=E[i].to;
if(to==father)continue;
dis[to][]=E[i].v;
dfs(to,now);
}
}
long long lca(int a,int b){
long long res=;
if(dep[a]<dep[b])swap(a,b);
for(int i=;i>=;i--)
if(dep[fa[a][i]]>=dep[b])
res+=dis[a][i],a=fa[a][i];
if(a==b)return res;
for(int i=;i>=;i--)
if(fa[a][i]!=fa[b][i]){
res+=dis[a][i],res+=dis[b][i];
a=fa[a][i],b=fa[b][i];
}
res+=dis[a][]+dis[b][];
return res;
}
int main(){
// freopen("Cola.txt","r",stdin);
freopen("prize.in","r",stdin);freopen("prize.out","w",stdout);
scanf("%d%d",&n,&m);
int x,y,z;
for(int i=;i<=m;i++){
scanf("%d%d%d",&x,&y,&z);
Insert(x,y,z);
Insert(y,x,z);
}
for(int i=;i<=n;i++)
if(!dfn[i])
{Tarjan(i,i);}
for(int con=;con<=gnum;con++)//枚举每个国家
for(int i=;i<g[con].size();i++){//枚举这个国家里的每个城市
int from=g[con][i];
for(int j=head[from];j;j=e[j].pre){
int to=e[j].to;
if(belong[from]!=belong[to]){
Insert2(belong[to],belong[from],e[j].v);
}
}
}
dfs(,);
for(int j=;j<=;j++){
for(int i=;i<=gnum;i++){
fa[i][j]=fa[fa[i][j-]][j-];
dis[i][j]=dis[i][j-]+dis[fa[i][j-]][j-];
}
}
for(int i=;i<=gnum;i++){
long long ans=;
for(int j=;j<=gnum;j++){
long long now=lca(i,j);
ans=max(ans,now);
}
w[i]=ans;
}
for(int i=;i<=n;i++){
printf(PLL"\n",w[belong[i]]);
}
}

60分 Tarjan缩点+倍增

2017-11-7 NOIP模拟赛的更多相关文章

  1. 11/1 NOIP 模拟赛

    11.1 NOIP 模拟赛 期望得分:50:实际得分:50: 思路:暴力枚举 + 快速幂 #include <algorithm> #include <cstring> #in ...

  2. 11.7 NOIP模拟赛

    目录 2018.11.7 NOIP模拟 A 序列sequence(two pointers) B 锁lock(思路) C 正方形square(埃氏筛) 考试代码 B C 2018.11.7 NOIP模 ...

  3. 2017 10.25 NOIP模拟赛

    期望得分:100+40+100=240 实际得分:50+40+20=110 T1 start取了min没有用,w(゚Д゚)w    O(≧口≦)O T3 代码3个bug :数组开小了,一个细节没注意, ...

  4. 2017.5.27 NOIP模拟赛(hzwer2014-5-16 NOIP模拟赛)

    期望得分:100+100+60+30=290 实际得分:100+20+60+0=180 当务之急:提高一次正确率 Problem 1 双色球(ball.cpp/c/pas) [题目描述] 机房来了新一 ...

  5. NOIP模拟赛-2018.11.7

    NOIP模拟赛 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 编译之前另存一份,听说如果敲 ...

  6. NOIP模拟赛-2018.11.6

    NOIP模拟赛 今天想着反正高一高二都要考试,那么干脆跟着高二考吧,因为高二的比赛更有技术含量(我自己带的键盘放在这里). 今天考了一套英文题?发现阅读理解还是有一些困难的. T1:有$n$个点,$m ...

  7. NOIP模拟赛-2018.11.5

    NOIP模拟赛 好像最近每天都会有模拟赛了.今天从高二逃考试跑到高一机房,然而高一也要考试,这回好像没有拒绝的理由了. 今天的模拟赛好像很有技术含量的感觉. T1:xgy断句. 好诡异的题目,首先给出 ...

  8. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  9. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  10. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

随机推荐

  1. mysql数据库更新

    在使用mysql数据库的时候,A方使用一个版本,B方在使用一个版本数据库进行开发使用,B方在开发的时候,有新的需求,需要添加表字段和所需要的表.但是A方已经在使用之前的版本数据库并且数据库里面有真实的 ...

  2. Python编程-一个小爬虫工具的实现过程

    需求描述: 1,打开网站: 2,获取网站的文件内容: 3,返回保存到文件中: 这里的就用到了多线程的方法 import requests,threading,time def write_html(u ...

  3. 关于ATML信号定义的理解-1

    1.XML中的类型标签: <xs:complexType>复合类型和<xs:simpleTyle>简单类型是数据结构类型,包含了各种类型的属性.可以被子类型继承,继承方式为&l ...

  4. Winform开发入门集中培训系列文章

    最近有个培训,写PPT不如写博客了,共享是程序猿的职业情操吧,因此,本人准备写一个Winform开发的系列文章,对于初级开发者来说,应该比较有用,写作当中不免错误或不成熟的地方,看到的朋友请留言指出, ...

  5. freeMarker(七)——程序开发指南之数据模型

    学习笔记,选自freeMarker中文文档,译自 Email: ddekany at users.sourceforge.net 1.基本内容 在入门章节中, 我们已经知道如何使用基本的Java类(M ...

  6. ffmpeg处理rtmp/文件/rtsp的推流和拉流

    ffmpeg处理rtmp/文件/rtsp的推流和拉流   本demo演示了利用ffmpeg从服务器拉流或本地文件读取流,更改流url或文件类型名称发送回服务器或存到本地的作用. 由于本程序只写了3个小 ...

  7. Swift中数组和字典都是值类型

    在 Swift 中,所有的基本类型:整数(Integer).浮点数(floating-point).布尔值(Boolean).字符串(string).数组(array)和字典(dictionary), ...

  8. 杂项-Log:NLog

    ylbtech-杂项-Log:NLog NLog是一个基于.NET平台编写的类库,我们可以使用NLog在应用程序中添加极为完善的跟踪调试代码. NLog是一个简单灵活的.NET日志记录类库.通过使用N ...

  9. oracle--事物---

    一.什么是事务 事务用于保证数据的一致性,它由一组相关的dml语句组成,该组的dml(数据操作语言,增删改,没有查询)语句要么全部成功,要么全部失败. 如:网上转账就是典型的要用事务来处理,用于保证数 ...

  10. Skyline实现橡皮筋效果绘制矩形框

    这种类似于框选的效果用的比较普遍,一般三维平台和GIS平台都提供了支持接口,可是Skyline就是这么傲娇! 思路是这样的:绘制出的矩形框应该是一直与屏幕边框平行的,也就是矩形框的实际旋转角度是等于摄 ...