提出 #17622365


ソースコード 拡げる

/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>
 
#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll power(ll b,ll x)
{
    ll temp = 1;
    for(ll i=1;i<=x;i++)
    {
        temp*=b;
    }
    return temp;
} 

bool check(ll x1)
{
    ll x = x1;
    ll b = -1;
    while (x!=0)
    {
        b++;
        x/=3;
    }
    debug(x1);
    debug(b); 
    if((ll)power(3,b)==x1)
    {
        return true;
    }   
    else
    {
        return false;
    }
    
}
void eff()
{
    ll n;
    sfl(n);
    ll a=-1,b=-1;
    ll p = 1;
    while((ll)power(5,p)<n)
    {
        ll mini = power((ll)5,p);
        ll x = n-mini;
        debug(mini);
        debug(x);
        if(check(x))
        {
            a=p;
            b = -1;
            while (x!=0)
            {
                b++;
                x/=3;
            }
            printf("%lld %lld\n",b,a);
            return;
        }
        ++p;
    }
    printf("-1\n");
}
 
int main()
{
    //fastio
    // ll test ;
    // sfl(test);
    // for(ll i=0;i<test;i++)
    // {
    //     printf("Case %lld:\n",i+1);
        eff();
        /* code */
    // }
//    cout<<check(81);
    return 0;
}

提出情報

提出日時
問題 A - 106
ユーザ AshiqPranto
言語 C++ (GCC 9.2.1)
得点 0
コード長 3590 Byte
結果 WA
実行時間 6 ms
メモリ 3784 KiB

コンパイルエラー

./Main.cpp: In function ‘void eff()’:
./Main.cpp:22:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   22 | #define sfl(a)  scanf("%lld",&a)
      |                 ~~~~~^~~~~~~~~~~
./Main.cpp:108:5: note: in expansion of macro ‘sfl’
  108 |     sfl(n);
      |     ^~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 300
結果
AC × 3
AC × 21
WA × 1
セット名 テストケース
Sample 00_sample_00, 00_sample_01, 00_sample_02
All 00_sample_00, 00_sample_01, 00_sample_02, 01_test_00, 01_test_01, 01_test_02, 01_test_03, 01_test_04, 01_test_05, 01_test_06, 01_test_07, 01_test_08, 01_test_09, 01_test_10, 01_test_11, 01_test_12, 01_test_13, 01_test_14, 01_test_15, 01_test_16, 01_test_17, 02_beet_killer
ケース名 結果 実行時間 メモリ
00_sample_00 AC 6 ms 3752 KiB
00_sample_01 AC 2 ms 3744 KiB
00_sample_02 AC 3 ms 3600 KiB
01_test_00 AC 3 ms 3784 KiB
01_test_01 AC 2 ms 3724 KiB
01_test_02 AC 3 ms 3716 KiB
01_test_03 AC 2 ms 3716 KiB
01_test_04 AC 3 ms 3640 KiB
01_test_05 AC 2 ms 3712 KiB
01_test_06 AC 2 ms 3716 KiB
01_test_07 AC 2 ms 3576 KiB
01_test_08 AC 2 ms 3580 KiB
01_test_09 AC 2 ms 3680 KiB
01_test_10 AC 1 ms 3512 KiB
01_test_11 AC 2 ms 3648 KiB
01_test_12 WA 2 ms 3748 KiB
01_test_13 AC 2 ms 3520 KiB
01_test_14 AC 3 ms 3648 KiB
01_test_15 AC 2 ms 3624 KiB
01_test_16 AC 2 ms 3648 KiB
01_test_17 AC 2 ms 3652 KiB
02_beet_killer AC 2 ms 3616 KiB