2017-10-04-afternoon

注意完全平方数统计时的特判
#include <cstdio> inline void read(int &x)
{
x=; register char ch=getchar();
for(; ch>''||ch<''; ) ch=getchar();
for(; ch>=''&&ch<=''; ch=getchar()) x=x*+ch-'';
}
const int N();
int n,cnt[N],ans; inline void Update(int x)
{
int i;
for(i=; i*i<x; ++i)
if(x%i==) cnt[i]++,cnt[x/i]++;
if(i*i==x) cnt[i]++;
} int Presist()
{
freopen("a.in","r",stdin);
freopen("a.out","w",stdout); read(n);
for(int op,x; n--; )
{
read(op),read(x);
if(op==) Update(x);
else ans^=cnt[x];
}
printf("%d\n",ans);
return ;
} int Aptal=Presist();
int main(int argc,char**argv){;}
AC

#include <cstring>
#include <cstdio> #define LL long long
inline void read(int &x)
{
x=; register char ch=getchar();
for(; ch>''||ch<''; ) ch=getchar();
for(; ch>=''&&ch<=''; ch=getchar()) x=x*+ch-'';
}
const int N(3e5+); int cnt[][N],val[N],dad[N];
int sumedge,head[N];
struct Edge {
int v,next,w;
Edge(int v=,int next=,int w=):v(v),next(next),w(w){}
}edge[N<<];
inline void ins(int u,int v,int w)
{
cnt[][u]++; cnt[][v]++;
edge[++sumedge]=Edge(v,head[u],w); head[u]=sumedge;
edge[++sumedge]=Edge(u,head[v],w); head[v]=sumedge;
} bool vis[N];
long long ans; inline void Add(int u)
{
for(; dad[u]; u=dad[u]) cnt[][dad[u]]++;
}
void DFS(int u,int fa,int pre)
{
for(int v,i=head[u]; i; i=edge[i].next)
{
v=edge[i].v;
if(vis[v]||fa==v||edge[i].w==pre) continue;
cnt[][v]++, dad[v]=u;
DFS(v,u,edge[i].w); Add(v); dad[v]=;
}
} int Presist()
{
freopen("b.in","r",stdin);
freopen("b.out","w",stdout);
int n; read(n);
for(int i=; i<=n; ++i) read(val[i]);
for(int u,v,w,i=; i<n; ++i)
read(u),read(v),read(w),ins(u,v,w);
for(int i=; i<=n; ++i)
if(cnt[][i]==) vis[i]=,DFS(i,,);
for(int i=; i<=n; ++i)
if(!vis[i]) vis[i]=,DFS(i,,);
for(int i=; i<=n; ++i)
ans+=1ll*cnt[][i]*val[i];
printf("%I64d\n",ans);
return ;
} int Aptal=Presist();
int main(int argc,char**argv){;}
额。。想法有问题

/*
呃呃呃
*/
未完成
2017-10-04-afternoon的更多相关文章
- Ubuntu 10.04 32位桌面版+OpnERP 6.1.1
1.准备环境: sudo apt-get install denyhosts sudo apt-get update sudo apt-get dist-upgrade sudo adduser ...
- [转]ubuntu 10.04下的配置tftp服务器
[转]ubuntu 10.04下的配置tftp服务器 http://www.cnblogs.com/geneil/archive/2011/11/24/2261653.html 第1步:安装tftp所 ...
- Ofbiz 10.04 + eclipse 安装与配置
1.下载 ofbiz 10.04:http://ofbiz.apache.org/download.html: 2.下载 freemarker-2.3.15 eclipse 插件(FreeMarker ...
- ubuntu 10.04 安装qt 5.0.2
转自ubuntu 10.04 安装qt 5.0.2 从qt project网站下载下来最新的qt5.0.2套件,发现是个.run文件,添加x属性,然后直接sudo ./****.run, 提示 /l ...
- 【转】Ubuntu 10.04 LTS 的窗口控制按钮从左上角调整到右上角
原文网址:http://www.linuxidc.com/Linux/2010-05/26111.htm 升级到Ubuntu 10.04后最大的问题,是最小最大和关闭按钮,放到了左边.这叫Ubuntu ...
- 解决:“Ubuntu 10.04 LTS _Lucid Lynx_ - Release i38...
编译android源码,找不到g++.通过apt-get下载时候,总是提示“Ubuntu 10.04 LTS _Lucid Lynx_ - Release i386 (20100429)” 的盘片插入 ...
- 九月 26, 2017 10:18:14 上午 com.sun.jersey.server.impl.application.RootResourceUriRules <init> 严重: The ResourceConfig instance does not contain any root resource classes.
Tomcat启动错误:九月 26, 2017 10:18:14 上午 com.sun.jersey.server.impl.application.RootResourceUriRules <i ...
- Ubuntu LTS 系统学习使用体会和实用工具软件汇总 6.04 8.04 10.04 12.04 14.04 16.04
Ubuntu LTS 系统学习体会和工具软件汇总 6.04 8.04 10.04 12.04 14.04 16.04 ubuntu入门必备pdf:http://download.csdn.net/de ...
- Using iSCSI On Ubuntu 10.04 (Initiator And Target)
This guide explains how you can set up an iSCSI target and an iSCSI initiator (client), both running ...
- Ubuntu 10.04下架设流媒体服务器
Ubuntu 10.04下架设流媒体服务器 个人建议:使用DarwinStreamingSrvr5.5.5,因为DarwinStreamingSrvr6.0.3安装过程中有很多问题需要解决! 目前主流 ...
随机推荐
- Oracle Storage in Action : 删除物理数据文件
ALTER TABLESPACE XH_DM DROP DATAFILE 'F:\DEV\ORACLE-DATA\ORCL\XH_DM_1.DBF'; SQL> ALTER TABLESPACE ...
- Clean Code 第十章 : 类
最近的CleanCode读到了第十章.这一张主要讲了如何去构造一个类,感觉的CleanCode至此已经不仅仅是单纯的讲如何'写'出漂亮的代码,而是从设计方向上去构造出好的代码了. 本章节主要讲了: * ...
- TensorFlow 安装 Win10 Python+GPU
前叙:有灵魂的程序都是每一个程序员的最终目标.TensorFlow了解下? 打算花几个月学机器学习,TensorFlow是很好的选择,折腾了会环境,略有心得分享下. 环境:win10 Python:3 ...
- C# 调用第三方DLL缓冲区溢出导致的异常
这个倒是少见的错误,纪录一下大佬. 先上异常 错误一:尝试读取或写入受保护的内存 错误二:未将对象引用设置到对象的实例 错误三: 托管调试助手“FatalExecutionEngineError”( ...
- log4j 日志分级处理
log4j 配置文件: log4j.rootLogger=debug,stdout,debug,info,errorlog4j.appender.stdout=org.apache.log4j.Con ...
- nvidia 的一些命令
直接在命令行使用 NVIDIA-smi会有问题 首先要确保电脑下了cuda. 然后打开cmd,使用cd命令进入: C:\Program Files\NVIDIA Corporation\NVSMI 然 ...
- STL || Gym 101653U Top 25
一组字符串给出两种排列方式, 求最小分成多少组 如 A A B C C D D B E E 则分成3组 A B C D E 即为1 3 1 #include < ...
- 剑指Offer(Python)
014-链表中倒数第k个结点 用快慢指针:p2比p1先走到k:间隔了k-1)步,然后再一起走,当p2为最后一个时,p1就为倒数第k个数 class ListNode: def __init__(sel ...
- Global Round 2
A - Ilya and a Colorful Walk CodeForces - 1119A Ilya lives in a beautiful city of Chordalsk. There a ...
- 自定义函数导致的sql性能问题
同事说,某某报表跑的很慢,让我调查一下 优化前:该报表整体需要跑4小时以上. sql代码如下 SELECT /*省略多数查询字段*/ REP_FUN_REFCODEVALUE /*自定义函数*/ (P ...