1001 Gaussian Prime

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=3798

.......................................我是真的一言难尽

1002 Sum of Factorials

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=2696

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 1000005
int a[];
void init()
{
a[]=a[]=;
for(int i=;i<;i++)
a[i]=a[i-]*i;
}
int main()
{
init();
int n;
while(~scanf("%d",&n),n>=)
{
if(n==)
{
printf("NO\n");
continue;
}
int all=;
for(int i=;i>=;i--)
{
all+=a[i];
if(all>n) all-=a[i];
}
if(all==n) printf("YES\n");
else printf("NO\n");
}
}

1003 Billboard

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=6016

黑板报h*w,第i个广告是1*wi。优先上、左。线段树存剩余最大容量。

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M 200005
int tre[M<<];
void build(int ind,int left,int right,int w)
{
tre[ind]=w;
if(left==right) return;
int mid=(left+right)>>;
build(ind*,left,mid,w);
build(ind*+,mid+,right,w);
tre[ind]=max(tre[ind*],tre[ind*+]);
}
int finda(int ind,int left,int right,int a)
{
if(left==right)
{
tre[ind]-=a;
return left;
}
int mid=(left+right)>>,ans;
if(tre[ind*]>=a) ans=finda(ind*,left,mid,a);
else ans=finda(ind*+,mid+,right,a);
tre[ind]=max(tre[ind*],tre[ind*+]);
return ans;
}
int main()
{
int h,w,n;
while(~scanf("%d%d%d",&h,&w,&n))
{
int minn=min(h,n);
build(,,minn,w);
while(n--)
{
int a;scanf("%d",&a);
if(tre[]<a) printf("-1\n");
else printf("%d\n",finda(,,minn,a));
}
}
}

1004 Monkey Party

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=6054

1005 Happy Necklace

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=6064

一点都不happy的项链,f(2)=3, f(3)=4, f(4)=6, f(n)=f(n-1)+f(n-2),矩阵快速幂。

  1    1    0

A = 0    0    1

  1    0    0

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+;
struct p{
ll rol,col;
ll matris[][];
};
p Matris(p a,p b)
{
p tem;
memset(tem.matris,,sizeof(tem.matris));
for(ll i=;i<;i++)
for(ll j=;j<;j++)
for(ll k=;k<;k++)
{
tem.matris[i][j]+=a.matris[i][k]*(b.matris[k][j]%mod);
tem.matris[i][j]%=mod;
}
return tem;
}
ll quick_mi(ll n)
{
p res,tep;
res.matris[][]=,res.matris[][]=,res.matris[][]=;
for(int i=;i<=;i++)
for(int j=;j<=;j++)
res.matris[i][j]=;
tep.matris[][]=,tep.matris[][]=,tep.matris[][]=;
tep.matris[][]=,tep.matris[][]=,tep.matris[][]=;
tep.matris[][]=,tep.matris[][]=,tep.matris[][]=;
while(n)
{
if(n&) res=Matris(res,tep);
tep=Matris(tep,tep);
n/=;
}
return res.matris[][]%mod;
}
int main()
{
int t;scanf("%d",&t);
while(t--)
{
ll n;scanf("%lld",&n);
if(n==) printf("3\n");
else if(n==) printf("4\n");
else if(n==) printf("6\n");
else printf("%lld\n",quick_mi(n-));
}
}

1006 CA Loves GCD

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=6068

我不爱

1007 Squarefree number

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=6071

欧拉筛把10^6内的素数标下,如果除了两个或以上就No。素数除完了可能还很大,就要看是不是完全平方数,否则n就是一个很大的素数或者两个大于10^6的素数乘积。

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 1000005
int prim[N+];
int vis[N+],cnt=;
void init()
{
vis[]=vis[]=;
for(int i=;i<N;i++)
if(!vis[i])
{
prim[cnt++]=i;
for(ll j=(ll)i*i;j<N;j+=i) vis[j]=;
}
}
int main()
{
init();
int t;scanf("%d",&t);
for(int kk=;kk<=t;kk++)
{
int flag=;
ll n;scanf("%lld",&n);
for(int i=;i<cnt;i++)
{
if(n%prim[i]==)
{
int num=;
while(n%prim[i]==) n/=prim[i],num++;
if(num>=)
{
flag=;
printf("Case %d: No\n",kk);
break;
}
}
}
if(n>&&flag)
{
int q=(int)sqrt(n);
if((ll)q*q==n) printf("Case %d: No\n",kk);
else printf("Case %d: Yes\n",kk);
continue;
}
if(flag) printf("Case %d: Yes\n",kk);
}
}

1008 Gym Class

http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=6081

选自己前面包括自己的最小id作为评分,记录一下要加上的评分minn。没有要求的入度为0进队列。

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e9;
const int N=;
vector<int> vec[N];
int inde[N];
priority_queue<int> q;
void init()
{
memset(inde,,sizeof(inde));
for(int i=;i<=N;i++) vec[i].clear();
while(!q.empty()) q.pop();
}
int main()
{
int t;scanf("%d",&t);
while(t--)
{
ll ans=,minn=MAXN;
init();
int n,m;scanf("%d%d",&n,&m);
while(m--)
{
int a,b;scanf("%d%d",&a,&b);
inde[b]++;
vec[a].push_back(b);
}
for(int i=;i<=n;i++)
if(!inde[i]) q.push(i);
while(!q.empty())
{
ll p=q.top();q.pop();
minn=min(p,minn);
ans+=minn;
for(int i=;i<vec[p].size();i++)
{
inde[vec[p][i]]--;
if(inde[vec[p][i]]==) q.push(vec[p][i]);
}
}
printf("%lld\n",ans);
}
}

2019/10/27 TZOJ的更多相关文章

  1. 2019/10/26 TZOJ

    1001 Flooded Island http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=452 ...

  2. 2019/10/13 TZOJ

    水题虽不好,但是很爽 渴望未来某天能把剩下的题补了,先做个记录. Hard Disk Drive http://acm.hdu.edu.cn/showproblem.php?pid=4788 单位转化 ...

  3. Alpha冲刺(4/10)——2019.4.27

    所属课程 软件工程1916|W(福州大学) 作业要求 Alpha冲刺(4/10)--2019.4.27 团队名称 待就业六人组 1.团队信息 团队名称:待就业六人组 团队描述:同舟共济扬帆起,乘风破浪 ...

  4. Beta冲刺(6/7)——2019.5.27

    所属课程 软件工程1916|W(福州大学) 作业要求 Beta冲刺(6/7)--2019.5.27 团队名称 待就业六人组 1.团队信息 团队名称:待就业六人组 团队描述:同舟共济扬帆起,乘风破浪万里 ...

  5. 背水一战 Windows 10 (27) - 控件(文本类): TextBlock

    [源码下载] 背水一战 Windows 10 (27) - 控件(文本类): TextBlock 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) TextBlock 示例 ...

  6. 第15次Scrum会议(10/27)【欢迎来怼】

    一.小组信息 队名:欢迎来怼 小组成员 队长:田继平 成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/27 17:20~17:45,总计25min. 地点 ...

  7. JZOJ 4269. 【NOIP2015模拟10.27】挑竹签

    4269. [NOIP2015模拟10.27]挑竹签 (File IO): input:mikado.in output:mikado.out Time Limits: 1000 ms  Memory ...

  8. 2019.10 搜索引擎最新排名,Elasticsearch遥遥领先

    大数据的搜索平台已经成为了众多企业的标配,Elasticsearch.Splunk(商业上市公司).Solr(Apache开源项目)是其中最为优秀和流行的选择.在2019.10 最新搜索引擎排名中,E ...

  9. [New!!!]欢迎大佬光临本蒟蒻的博客(2019.11.27更新)

    更新于2019.12.22 本蒟蒻在博客园安家啦!!! 本蒟蒻的博客园主页 为更好管理博客,本蒟蒻从今天开始,正式转入博客园. 因为一些原因,我的CSDN博客将彻底不会使用!!!(带来不便,敬请谅解) ...

随机推荐

  1. js如何实现上拉加载更多...

    我们在项目中经常使用到下拉加载更多,之前要么是底部写加载按钮,要么是引入插件.今天终于有时间手写一个了,之前感觉挺麻烦,明白原理后,其实很简单... scrollTop:滚动视窗的高度距离window ...

  2. linux相关(find/grep/awk/sed/rpm)

    如何查找特定的文件: find :在指定目录下查找文件 find -name "filename" :从当前目录查找文件 find / -name "filename&q ...

  3. SQL 常用语句(一)

    --SQL 语句为表添加字段并设置默认值 alter table TableName add ColumnName int --字段类型 not null --是否为空 --默认值 --SQL 语句为 ...

  4. Webpack和Gulp对比

    Webpack和Gulp对比 作者 彬_仔 关注 2016.10.19 22:42* 字数 8012 阅读 2471评论 18喜欢 68 在现在的前端开发中,前后端分离.模块化开发.版本控制.文件合并 ...

  5. Linux常用指令全集

    Linux简介及Ubuntu安装 常见指令 系统管理命令 打包压缩相关命令 关机/重启机器 Linux管道 Linux软件包管理 vim使用 用户及用户组管理 文件权限管理 大牛笔记-www.weix ...

  6. JavaScript——call() 方法

    function Product(name, price) { this.name = name; this.price = price; } function Food(name, price) { ...

  7. postman断言

    较旧的写作邮差测试风格 较旧的Postman测试编写风格依赖于特殊tests对象的设置值.您可以为对象中的元素设置描述性键,然后说明它是真还是假.例如,tests["Body contain ...

  8. adb 链接网络 connect 安装apk install 断开IP链接 kill-server 连接数devices

    https://blog.csdn.net/zhonglunshun/article/details/78362439 ./adb connetc 192.168.1.11 ./adb install ...

  9. 【记录】spring boot 全局捕获异常@ExceptionHandler与@Validated @RequestBody 配合使用

    @ExceptionHandler与@Validated @RequestBody 三者配合使用可以很好的做到入参校验,具体demo如下: 接口 import org.springframework. ...

  10. hdu 4625 Dice(概率DP)

    Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submi ...