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

 #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. Deprecated: Assigning the return value of new by reference is deprecated in报错

    出现了Deprecated: Assigning the return value of new by reference is deprecated in wwwroot\common.inc.ph ...

  2. js递归和数组去重(简单便捷的用法)

    1.递归例子<script type="text/javascript"> function test(num) { if(num < 0) { return; ...

  3. codevs 1316 文化之旅 2012年NOIP全国联赛普及组

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 有一位使者要游历各国,他每到一个国家,都能学到一种文化,但他不愿意学习任何一种文 ...

  4. github 下载全部项目

    从github下载资料过程中,有些项目含有子模块,有时通过git clone 或者下载zip方式项目可能会缺少文件,因此需要执行 git submodule update --init --recur ...

  5. windows快捷键cmd中

    windows 中cmd中命令: cls  ---------> 清屏 dir ----------> 获取目录 Ctrl + c ----> 结束当前命令 cd .. ------ ...

  6. windows下安装python

    1. 进入python官网   https://www.python.org/downloads/windows/ 2.根据我们的电脑位数选择版本,尽量选择  Download Windows x86 ...

  7. DROP USER - 删除一个数据库用户帐号

    SYNOPSIS DROP USER name DESCRIPTION 描述 DROP USER 从数据库中删除指定的用户. 它不删除数据库里此用户所有的表,视图或其他对象. 如果该用户拥有任何数据库 ...

  8. DFS || HDU 2181

    题意:一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市. 前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每 ...

  9. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown error 1146

    问题介绍:   com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown error 1146 MySql语法错误, 但是错 ...

  10. mybatis-5 手写代理

    @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Select { public St ...