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

推荐订阅源

量子位
S
Securelist
MyScale Blog
MyScale Blog
Jina AI
Jina AI
罗磊的独立博客
The Cloudflare Blog
美团技术团队
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
雷峰网
雷峰网
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
博客园 - 聂微东
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
T
Tailwind CSS Blog
Attack and Defense Labs
Attack and Defense Labs
博客园_首页
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Hacker News
The Hacker News
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
D
Docker
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Security Latest
Security Latest
V2EX - 技术
V2EX - 技术
N
News | PayPal Newsroom
Microsoft Security Blog
Microsoft Security Blog

博客园 - xmx

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

//数论题,,,,这个做法是正向加求和算的,当然应该也可以反向求出不符合规定的数目,然后减去
#include <iostream>
using namespace std;
__int64 tt(int x,int y)
{
__int64 sum=1;
int i,j;
for(i=0,j=1;i<y;i++)
{
   sum*=(x-i);
   for(;j<=y&&sum%j==0;j++) sum/=j;
}
return sum;
}
int main()
{
string s;
__int64 n;
int i,j;
while(cin>>s)
{
    for(i=0;s[i+1];i++)
    {
     if(s[i]>=s[i+1]) break;
    }
    if(s[i+1]) cout<<0<<endl;
    else
    {
     i=s.length();
     for(--i,n=0;i;i--)
      n+=tt(26,i);
     for(i=0;s[i];i++)
     {
      if(i==0)j='a';
      else j=s[i-1]+1;
      for(;j<s[i];j++)
      {
       n+=tt('z'-j,s.length()-i-1);
      }
     }
     cout<<n+1<<endl;
    }
}
return 0;
}

posted on 2007-10-03 19:58  xmx  阅读(418)  评论()    收藏  举报