hdu 6043 KazaQ's Socks
2017-07-26 15:07
260 查看
规律题。我自己写的规律对长度为2的要特判,wa一万次。。。
规律题目,容易错的反而是数据小的时候,得长记性。
题解:规律 先是1~n 然后1~n-2 n-1 1~n-2 n 交替出现
比如当n=4 的时候 1 2 3 4 1 2 3 1 2 4 1 2 3 1 2 4 ......
AC代码:
规律题目,容易错的反而是数据小的时候,得长记性。
题解:规律 先是1~n 然后1~n-2 n-1 1~n-2 n 交替出现
比如当n=4 的时候 1 2 3 4 1 2 3 1 2 4 1 2 3 1 2 4 ......
AC代码:
#include <cstdio> #include <iostream> using namespace std; typedef long long ll; int main() { int Case=1; ll n,m; while(cin>>n>>m) { if(n==2)// 注意对2 特判。 { if(m%2) printf("Case #%d: %lld\n",Case,(ll)1); else printf("Case #%d: %lld\n",Case,(ll)2); Case++; continue; } if(m<=n) { printf("Case #%d: %lld\n",Case,m); Case++; continue; } ll temp=m-n; ll ret=temp/(n-1); ll zz=temp%(n-1); if(zz!=0) { printf("Case #%d: %lld\n",Case,zz); } else { if(ret%2) { printf("Case #%d: %lld\n",Case,n-1); } else printf("Case #%d: %lld\n",Case,n); } Case++; } }
相关文章推荐
- 2017 Multi-University Training Contest - Team 1 1011&&HDU 6043 KazaQ's Socks【规律题,数学,水】
- HDU 6043 - KazaQ's Socks | 2017 Multi-University Training Contest 1
- 2017杭电多校联赛 1011 KazaQ's Socks(找规律)HDU 6043
- HDU 6043 KazaQ's Socks - 2017多校联盟1 第11题 -规律
- HDU 6043 KazaQ's Socks
- 【多校训练】hdu 6043 KazaQ's Socks
- 17 多校 - 1 - 1011 - KazaQ's Socks (HDU 6043)
- HDU 6043 KazaQ's Socks
- hdu 6043 KazaQ's Socks 模拟
- HDU 6043(2017 多校训练赛1 1011) KazaQ's Socks
- HDU 6043 KazaQ's Socks(暑期训练1011)
- HDU 6043 KazaQ's Socks(周期)
- 17暑假多校联赛1.11 HDU 6043 KazaQ's Socks
- HDU 6043(KazaQ's Socks) 规律题 Java
- HDU 6043 KazaQ's Socks【规律】
- HDU 6043 KazaQ's Socks 找规律
- (数学)HDU 6043 KazaQ's Socks
- HDU 6043 KazaQ's Socks 【规律】
- HDU 6043 KazaQ's Socks(水~)
- 【HDU】6043 - KazaQ's Socks(思维)