zoukankan      html  css  js  c++  java
  • Robbers' watch CodeForces

    大意: 一天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 '
    '
    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;}
    //head
    
    
    
    
    const 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
    ", ans);
    }
    
  • 相关阅读:
    [CF724G]Xor-matic Number of the Graph
    [SOJ #537]不包含 [CF102129I]Incomparable Pairs(2019-8-6考试)
    [SOJ #538]好数 [CC]FAVNUM(2019-8-6考试)
    [洛谷P4052][JSOI2007]文本生成器
    [洛谷P3966][TJOI2013]单词
    [洛谷P5158]【模板】多项式快速插值
    [洛谷P3227][HNOI2013]切糕
    【bzoj】3477: [Usaco2014 Mar]Sabotage 01分数规划
    【SPOJ
    【以前的空间】系列
  • 原文地址:https://www.cnblogs.com/uid001/p/10618067.html
Copyright © 2011-2022 走看看