Robbers' watch CodeForces - 685A (暴力)
生活随笔
收集整理的這篇文章主要介紹了
Robbers' watch CodeForces - 685A (暴力)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
大意: 一天n小時, m分鐘, 表以7進制顯示, 求表顯示數字不同的方案數
?
注意到小時和分鐘部分總長不超過7, 可以直接暴力枚舉.
關鍵要特判0, 0的位數要當做1來處理
#include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #include <string.h> #include <bitset> #define REP(i,a,n) for(int i=a;i<=n;++i) #define PER(i,a,n) for(int i=n;i>=a;--i) #define hr putchar(10) #define pb push_back #define lc (o<<1) #define rc (lc|1) #define mid ((l+r)>>1) #define ls lc,l,mid #define rs rc,mid+1,r #define x first #define y second #define io std::ios::sync_with_stdio(false) #define endl '\n' using namespace std; typedef long long ll; typedef pair<int,int> pii; const int P = 1e9+7, INF = 0x3f3f3f3f; ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;} ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;} ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;} //headconst int N = 1e6+10; int x, y, tx, ty, vis[N]; int chk(int x, int y) {REP(i,0,6) vis[i]=0;REP(i,1,tx) ++vis[x%7],x/=7;REP(i,1,ty) ++vis[y%7],y/=7;REP(i,0,6) if (vis[i]>1) return 0;return 1; }int main() {scanf("%d%d", &x, &y), --x, --y;if ((ll)x*y>6543210) return puts("0"),0;for (int i=x; i; i/=7) ++tx;for (int i=y; i; i/=7) ++ty;tx = max(tx,1), ty = max(ty,1);int ans = 0;REP(i,0,x) REP(j,0,y) ans+=chk(i,j);printf("%d\n", ans); }?
轉載于:https://www.cnblogs.com/uid001/p/10618067.html
總結
以上是生活随笔為你收集整理的Robbers' watch CodeForces - 685A (暴力)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux系统怎么安装exe软件?
- 下一篇: 面试趣味题