0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AtCoder 生活 97日目

Posted at

前回

#97日目
今回はABC178のA〜C問題をときました。

|問題|難易度|自力で解けた|かかった時間|
|:-:|:-:|:-:|---|---|
|ABC178|A|◯|45秒|
|ABC178|B|◯|2分23秒|
|ABC178|C|✕|68分47秒|

##ABC178

###A


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    int x;
    cin >> x;
    if(x == 1)cout << 0 << endl;
    else cout << 1 << endl;
}

解くのにかかった時間:45秒

###B


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ans = max({a*c,a*d,b*c,b*d});
    cout << ans << endl;
}

解くのにかかった時間:2分23秒

###C


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const ll MOD = 1e9+7;

int p(int x,ll n){
    ll a = x;
    rep(i,n-1){
        a = a*x%MOD;
    }
    return a;
}

int main(){
    ll n;
    cin >> n;
    ll a = p(10,n);
    ll b = p(9,n);
    ll c = p(8,n);
    ll ans = (a - b - b + c)%MOD;
    ans = (ans + MOD)%MOD;
    cout << ans << endl;
}

解くのにかかった時間:68分47秒
感想:最後にMODを足してMODで余りを出す理由を知りたい

###最後に
Cの回答がなぜこれで通るのかわからなかった

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?