結果

問題 No.211 素数サイコロと合成数サイコロ (1)
ユーザー gamma_kprgamma_kpr
提出日時 2020-10-23 17:46:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 6,193 bytes
コンパイル時間 1,898 ms
コンパイル使用メモリ 180,596 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 15:37:20
合計ジャッジ時間 3,920 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘long long int fibonatti(long long int)’ 内:
main.cpp:40:12: 警告: ‘temp’ may be used uninitialized [-Wmaybe-uninitialized]
   40 |     return count;
      |            ^~~~~
main.cpp:25:15: 備考: ‘temp’ はここで定義されています
   25 |     long long temp;
      |               ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*素数判定*/
bool isPrime(int x){
    int i;
    if(x < 2){
        return 0;
    }else if(x == 2){
        return 1;
    }
    if(x%2 == 0) {
        return 0;
    }
    for(i = 3; i*i <= x; i += 2){
        if(x%i == 0){
            return 0;
        }
    }
    return 1;
}

/*桁和*/
int digsum(int n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

/*約数の数*/
long long countdivisor(long long K){
    long long N = sqrt(K);
    bool b = false;
    if(sqrt(K)-N==0){
        b= true;
    }
    long long count =0;
    for(int i=0;i<N;i++){
        if(K%(i+1)==0){
            count++;
        }
    }
    if(b==false){
        count *= 2;
    }else{
        count = (count-1)*2+1;
    }
    return count;
}

/*約数列挙*/
vector<long long> Alldivisor(long long n){
    vector<long long> ret;
    for(int i=1;i*i<=n;i++){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}
/**/
template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        if(tmp!=0) ret.push_back(make_pair(i, tmp));
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}

/*特定の文字カウント*/
int stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

/*Graph*/
using Graph = vector<vector<int>>; //グラフ型
struct Edge{
    int to; //辺の行き先
    int weight; //辺の重み
    Edge(int t,int w):to(t),weight(w){}
};
using WGraph = vector<vector<Edge>>;
/*vector<int> first_order; //行きがけ順
vector<int> last_order; //帰りがけ順 */
/*重みなし有向*/
Graph WeightlessGraph(int N,int M){
    Graph G(N);
    vector<bool> m(N,false);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
    }
    return G;
}
/*重みなし無向*/
Graph WeightlessNoDirectionGraph(int N,int M){
    Graph G(N);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    return G;
}
/*重みつき*/
WGraph WeightGraph(int N,int M){
    WGraph G(N);
    for(int i=0;i<M;i++){
        int from, to ,weight;
        cin >> from >> to >> weight;
        G[from].push_back(Edge(to,weight));
    }
    return G;
}
/*深さ優先探索*/
vector<bool> seen;
//vector<ll> ans;
void dfs(const Graph &G, int s,int p){
    seen[s]=true;
    /*if(p!=-1){
        ans[s]+=ans[p];
    }*/
    for(auto next_v:G[s]){
        if(seen[next_v]){
            continue;
        }
        dfs(G,next_v,s);
    }
}
/*1以外の素因数の個数*/
long long prime_counter(long n) {
    long long count=0;
    bool ch = false;
    for (long i = 2; i * i <= n; i++) {
        long long tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
            ch = true;
        }
        if(ch == true) count++;
        ch = false;
    }
    if (n != 1) count++;
    return count;
}

long long divisor(long long n){
    int i=sqrt(n);
    while(true){
        if(n%i == 0){
            return i;
        }
        i--;
    }
}
/*ここから*/
int main() {
    int K;
    cin >> K;
    vector<int> p(6),n(6);
    p = {2,3,5,7,11,13};
    n = {4,6,8,9,10,12};
    vector<int> t(36);
    int count = 0;
    for(int i=0;i<6;i++){
        for(int j=0;j<6;j++){
            if(p[i]*n[j]==K){
                count++;
            }
        }
    }
    double ans = 0;
    for(int i=0;i<count;i++){
        double a = 1/(double)36;
        ans += a;
    }
    printf("%.15f\n", ans);
    return 0;
}
/*REの時vectorのoverflow確認*/
0