CodeForces 628B New Skateboard
来源:互联网 发布:手机淘宝怎么发帖 编辑:程序博客网 时间:2024/05/17 00:59
FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
All Copyright Reserved ©2010-2014 HUST ACM/ICPC TEAM
题意:从所给字符串中:找到多少个4的倍数的子串。
方法;一个子串的后两位能整除4那么这个子串就能整除4,所以枚举每相邻两位看是否能整除4即可 ;
<span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><iostream></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><algorithm></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><cstdio></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><cstring></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><cmath></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><queue></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><cctype></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span> <span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><map></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#include</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><stdio.h></span><span class="sh-preproc" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 184, 0);">#define</span> INF <span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">0x3f3f3f3f</span><span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">typedef</span> <span class="sh-type" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255);">long</span> <span class="sh-type" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255);">long</span> ll<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span><span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">using</span> <span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">namespace</span> std<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span><span class="sh-type" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255);">char</span> str<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">[</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">300010</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">];</span><span class="sh-type" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255);">int</span> <span class="sh-function" style="margin: 0px; padding: 0px; line-height: 1.1em; font-weight: bold;">main</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">()</span><span class="sh-cbracket" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">{</span> <span class="sh-usertype" style="margin: 0px; padding: 0px; line-height: 1.1em;">ll</span><span class="sh-normal" style="margin: 0px; padding: 0px; line-height: 1.1em;"> </span>ans<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span> <span class="sh-type" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255);">int</span> i<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">,</span>len<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span> <span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">while</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">(</span><span class="sh-function" style="margin: 0px; padding: 0px; line-height: 1.1em; font-weight: bold;">scanf</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">(</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">"%s"</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">,</span>str<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)!=</span>EOF<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)</span> <span class="sh-cbracket" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">{</span> len<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">=</span><span class="sh-function" style="margin: 0px; padding: 0px; line-height: 1.1em; font-weight: bold;">strlen</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">(</span>str<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">);</span> ans<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">=</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">0</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span> <span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">for</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">(</span>i<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">=</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">0</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span>i<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);"><</span>len<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span>i<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">++)</span> <span class="sh-cbracket" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">{</span> <span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">if</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">((</span>str<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">[</span>i<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">]-</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">'0'</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)%</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">4</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">==</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">0</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)</span> ans<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">=</span>ans<span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">+1</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span> <span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">if</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">(((</span>str<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">[</span>i<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">]-</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">'0'</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)+(</span>str<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">[</span>i<span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">-1</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">]-</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">'0'</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)*</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">10</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)%</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">4</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">==</span><span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">0</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">)</span> ans<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">=</span>ans<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">+</span>i<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span> <span class="sh-cbracket" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">}</span> <span class="sh-function" style="margin: 0px; padding: 0px; line-height: 1.1em; font-weight: bold;">printf</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">(</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">"%I64d</span><span class="sh-specialchar" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(196, 45, 168);">\n</span><span class="sh-string" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">"</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">,</span>ans<span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">);</span> <span class="sh-cbracket" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">}</span> <span class="sh-keyword" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(0, 0, 255); font-weight: bold;">return</span> <span class="sh-number" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(169, 0, 169);">0</span><span class="sh-symbol" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">;</span><span class="sh-cbracket" style="margin: 0px; padding: 0px; line-height: 1.1em; color: rgb(255, 0, 0);">}</span>
0 0
- codeforces 628 B. New Skateboard
- codeforces 628B New Skateboard
- CodeForces 628B New Skateboard
- CodeForces 628B New Skateboard
- CodeForces 628B New Skateboard
- CodeForces 628B New Skateboard
- CodeForces 628 B New Skateboard
- codeforces 628B New Skateboard
- Codeforces 628B New Skateboard (数学)
- Codeforces 628B New Skateboard【数学】
- CodeForces 628 B. New Skateboard(水~)
- CodeForces 628B New Skateboard (数学)
- Codeforces 628B New Skateboard【数学】
- (CodeForces 628B)New Skateboard
- 【CodeForces 628B】 New Skateboard (数学水)
- codeforces 628 B. New Skateboard (数学-被4整除)
- CF 628B. New Skateboard
- Educational Codeforces Round 8-B. New Skateboard
- [布局效率问题]解决ListView的getview调用次数多于子view个数的问题
- CodeForces 628A Tennis Tournament
- C++第五次上机实验
- BNUOJ-20950-沉重的货物(最小生成树的Prim算法)
- 百钱买百鸡最优解
- CodeForces 628B New Skateboard
- Android中短信的收发
- 《深入浅出JavaScript(中文版)》读后记录
- 【问题】sql数据库安装重启失败
- c++上机作业5
- 获取select option自定义元素的值
- 两端输出字符,从两端移动向中间汇聚; 模拟三次密码输入
- POJ 1125 Stockbroker Grapevine
- 安卓动态调试七种武器之离别钩 – Hooking(下)