GCD XOR, ACM/ICPC Dhaka 2013, UVa12716
不同的枚举方法,效率完全不同。值得记录一下!
#include <cstdio>
#include <cstring>
int t, a, b, c, n, cas = , count = ;
int cnt[];
void pre() {
count = ;
memset(cnt, , sizeof(cnt)); for (a = ; a <= ; a++) {
for (c = ; c < a; c++) {
if (a%c == && ((a-c)^a)==c) {
count++;
}
}
cnt[a-] = count;
} }
int main(void)
{ for (scanf("%d", &t); t--;) {
scanf("%d", &n);
printf("Case %d: %d\n", ++cas, cnt[n-]);
}
return ;
}
#include <cstdio>
#include <cstring>
int t, a, b, c, n, cas = , count = ;
const int maxn = ;
int cnt[maxn];
void pre() {
count = ;
memset(cnt, , sizeof(cnt)); for (c = ; c <= maxn/; c++) {
for (a = c+c; a <= maxn; a+=c) {
if (((a-c)^a)==c) {
cnt[a]++;
}
}
}
for (int i = ; i <= maxn; i++) {
cnt[i] += cnt[i-];
} }
int main(void)
{
pre();
for (scanf("%d", &t); t--;) {
scanf("%d", &n);
printf("Case %d: %d\n", ++cas, cnt[n]);
}
return ;
}
GCD XOR, ACM/ICPC Dhaka 2013, UVa12716的更多相关文章
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków
ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków Problem A: Rubik’s Rect ...
- hduoj 4710 Balls Rearrangement 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4710 Balls Rearrangement Time Limit: 6000/3000 MS (Java/Ot ...
- hduoj 4708 Rotation Lock Puzzle 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4708 Rotation Lock Puzzle Time Limit: 2000/1000 MS (Java/O ...
- hduoj 4715 Difference Between Primes 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Time Limit: 2000/1000 MS (J ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
- hduoj 4707 Pet 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4707 Pet Time Limit: 4000/2000 MS (Java/Others) Memory ...
- hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4706 Children's Day Time Limit: 2000/1000 MS (Java/Others) ...
- ACM - ICPC World Finals 2013 C Surely You Congest
原题下载:http://icpc.baylor.edu/download/worldfinals/problems/icpc2013.pdf 题目翻译: 试题来源 ACM/ICPC World Fin ...
随机推荐
- uploadify firefox 401
uploadify在firefox下上传会报401错误:这是因为java的框架把其拦截了 拦截的原因是,firefox下的flash在请求和发送请求的时候不会携带cookie和session过去,造成 ...
- JavaScript中sort方法的一个坑(leetcode 179. Largest Number)
在做 Largest Number 这道题之前,我对 sort 方法的用法是非常自信的.我很清楚不传比较因子的排序会根据元素字典序(字符串的UNICODE码位点)来排,如果要根据大小排序,需要传入一个 ...
- Android热修复实践应用--AndFix
一直关注App的热修复的技术发展,之前做的应用也没用使用到什么热修复开源框架.在App的热修复框架没有流行之前,做的应用上线后发现一个小小的Bug,就要马上发一个新的版本.我亲身经历过一周发两个版本, ...
- 【技巧】“Plugin execution not covered by lifecycle configuration...“异常的处理
问题现象: 在Eclipse(JEE mars)中新建maven project,选择archetype为:maven-archetype-plugin,结果生成的project存在错误:“Plugi ...
- NetFPGA
From Wikipedia, the free encyclopedia The NetFPGA project[1] is an effort to develop open source har ...
- Go--避免SQL注入
避免SQL注入 什么是SQL注入 SQL注入攻击(SQL Injection),简称注入攻击,是Web开发中最常见的一种安全漏洞.可以用它来从数据库获取敏感信息,或者利用数据库的特性执行添加用户,导出 ...
- 消息队列写入内容后,读出来的自动包裹了<string>标签,自定义格式化器解决该issue
/// <summary> /// 该格式化器使输入即输出 /// </summary> public class StringFormatter : IMessageForm ...
- 怎样设置Word下次打开时跳转到上次阅读的位置
①我们启动Word2013,打开需要阅读的文档,当阅读完毕之后,在指定位置键入一个空格,然后按下Delete键删除,这样相当于是没有作任何更改. ②保存文档,单击文件--另存为,选择好路径,将文档保存 ...
- 跨浏览器图像灰度(grayscale)解决方案
<style type="text/css"> .gray { -webkit-filter: grayscale(100%); /* CSS3 filter方式,we ...
- Ajax 是什么?Ajax 的交互模型?同步和异步的区别?如何解决跨域问题?以及 HTTP状态码
一.Ajax 是什么: 1. 通过异步模式,提升了用户体验 2. 优化了浏览器和服务器之间的传输,减少不必要的数据往返,减少了带宽占用 3. Ajax 在客户端运行,承担了一部分本来由服务器承担的工作 ...