惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Exploit Database - CXSecurity.com
A
Arctic Wolf
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cisco Blogs
AWS News Blog
AWS News Blog
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
美团技术团队
T
Threatpost
S
Schneier on Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cyber Attacks, Cyber Crime and Cyber Security
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
Blog — PlanetScale
Blog — PlanetScale
C
Cybersecurity and Infrastructure Security Agency CISA
F
Full Disclosure
博客园_首页
N
Netflix TechBlog - Medium
Security Latest
Security Latest
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Register - Security
The Register - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Recent Announcements
Recent Announcements
博客园 - Franky
P
Palo Alto Networks Blog
Project Zero
Project Zero
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Cisco Talos Blog
Cisco Talos Blog
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 【当耐特】
GbyAI
GbyAI

博客园 - xmx

Amazon 2面杯具 N皇后回溯 "中航文化杯" 2007 ACM/ICPC 国际大学生程序设计竞赛亚洲区域赛(南京) 一个用来练dfs的简单迷宫问题 pku 1806 Manhattan 2025(找规律) 今天西华的比赛,啥都不说啦,相当的nice!~~~ 今天北京赛区的比赛 pku 1505 copying books(DP) 最近看的一些东西 The 2007 ACM Asia Programming Contest Changchun Site Internet Preliminary Contest nice 位运算果真是好东西,今天算是学到点啦^_^ FOJ月赛-2007年9月 pku 1850 前面一直没注意到某个不规范的情况,导致结果一直比标准的大...调了好久... 终于有算最长重复子串(数)的后缀数组啦,nice The 2007 ACM Asia Programming Contest - Nanjing Preliminary pku 3219 人家居然用几十B就过了,肯定有超强的规律,可是我自己找了个,挂了...只能老实算... 一道双向dp,差点超时^_^||| dp pku 1050 N和素数P,求杨辉三角第N行中能被P整除的数的个数
pku 1662 还是找规律的
xmx · 2007-10-16 · via 博客园 - xmx

说明:这道题目感觉比较难想,开始我真的拿出了几枚硬币在那边试,试着把比较小的情况找出来,看能够找到一般的规律;
结果发现:似乎是部分有规律,还有的看着有规律,但是很难统一起来...到最后终于发现了似乎总的翻的次数和硬币总数有关,是硬币数的整数倍或者整数倍减一,(这个到现在我也不知道为什么),然后试着看某枚硬币回到原来状态需要多少,然后这样做,结果就对了^_^
#include<stdio.h>
int main()
{
 int t,n,k,k0,p,flag,ch;
 scanf("%d",&t);
 while(t--)
 {
  scanf("%d",&n);
  if(n==1)
  {
   printf("2\n");
   continue;
  }
  k=n/2,k0=n%2;
  p=1,flag=0,ch=0;
  if(k0)
  {
   do
   {
    if(p%2)
    {
     flag=1-flag;
     p=k+1-p/2;
    }
    else p=k+1+p/2;   
    ch++;
   }while(p!=1);
  }
  else
  {
   do
   {
    if(p%2)
     p=k+(p+1)/2;
    else
    {
     flag=1-flag;
     p=k-p/2+1;
    }   
    ch++;
   }while(p!=1);
  }
  __int64 ch2=ch;
  __int64 ans=ch2*n-flag;
  printf("%I64d\n",ans);
 }
 return 0;
}

posted on 2007-10-16 21:28  xmx  阅读(461)  评论()    收藏  举报