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

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - 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)  评论()    收藏  举报