注意完全平方数统计时的特判

 #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的更多相关文章

  1. 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 ...

  2. [转]ubuntu 10.04下的配置tftp服务器

    [转]ubuntu 10.04下的配置tftp服务器 http://www.cnblogs.com/geneil/archive/2011/11/24/2261653.html 第1步:安装tftp所 ...

  3. Ofbiz 10.04 + eclipse 安装与配置

    1.下载 ofbiz 10.04:http://ofbiz.apache.org/download.html: 2.下载 freemarker-2.3.15 eclipse 插件(FreeMarker ...

  4. ubuntu 10.04 安装qt 5.0.2

    转自ubuntu 10.04 安装qt 5.0.2 从qt project网站下载下来最新的qt5.0.2套件,发现是个.run文件,添加x属性,然后直接sudo ./****.run, 提示  /l ...

  5. 【转】Ubuntu 10.04 LTS 的窗口控制按钮从左上角调整到右上角

    原文网址:http://www.linuxidc.com/Linux/2010-05/26111.htm 升级到Ubuntu 10.04后最大的问题,是最小最大和关闭按钮,放到了左边.这叫Ubuntu ...

  6. 解决:“Ubuntu 10.04 LTS _Lucid Lynx_ - Release i38...

    编译android源码,找不到g++.通过apt-get下载时候,总是提示“Ubuntu 10.04 LTS _Lucid Lynx_ - Release i386 (20100429)” 的盘片插入 ...

  7. 九月 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 ...

  8. 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 ...

  9. 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 ...

  10. Ubuntu 10.04下架设流媒体服务器

    Ubuntu 10.04下架设流媒体服务器 个人建议:使用DarwinStreamingSrvr5.5.5,因为DarwinStreamingSrvr6.0.3安装过程中有很多问题需要解决! 目前主流 ...

随机推荐

  1. http接口调用,传递json格式带双引号问题

    springmvc 配置好会自动转换json格式,只要配置他转格式之前,在转次String类型就好

  2. 合并百度影音的离线数据 with python 2.3 格式更新

    很久没有更新了. 这次新增支持四种格式的解析. filelist slicelist download.cfg third_party_download.cfg 还是2个文件.替换之前版本即可. 初步 ...

  3. linux之awk命令

    一.awk的内置参数 $0:表示整个当前行 $1:每行第一个字段 $2:每行第二个字段 $n:每行第n个字段 awk的参数:分隔符 -F separator 设定分隔符(默认为空格) 打印单个字段: ...

  4. svn批处理语句

    sc create SVNService binpath="O:\ProgramingSoftware\SuiVersion\bin\svnserve.exe --service -r E: ...

  5. this.$emit('on-select-change' emit里面不能写大写字母

    this.$emit('on-select-change' emit里面不能写大写字母 刚试了下 也能写大写 但是 两边就都写一样就完了,就都写成带-的就完了

  6. Object.assign(o1, o2, o3) 对象 复制 合拼

    Object 对象方法学习之(1)—— 使用 Object.assign 复制对象.合并对象 合并对象 var o1 = {a: 1}; var o2 = {b: 2}; var o3 = {c: 3 ...

  7. Java数据结构和算法(四)--链表

    日常开发中,数组和集合使用的很多,而数组的无序插入和删除效率都是偏低的,这点在学习ArrayList源码的时候就知道了,因为需要把要 插入索引后面的所以元素全部后移一位. 而本文会详细讲解链表,可以解 ...

  8. HDU4300 Clairewd’s message(拓展kmp)

    Problem Description Clairewd is a member of FBI. After several years concealing in BUPT, she interce ...

  9. Linux下使用vi命令后退出方式

    退出Vi         当编辑完文件,准备退出Vi返回到shell时,可以使用以下几种方法之一.         在命令模式中,连按两次大写字母Z,若当前编辑的文件曾被修改过,则Vi保存该文件后退出 ...

  10. TP框架中同时使用“or”和“and”

    今天在tp中遇到一个问题,可能这并不算难的问题,但是我还是分享一下 以下是tp手册里面查询or的方式 $User = M("User"); // 实例化User对象 $where[ ...