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.

Atcorder152 A~C問題

Posted at

Atcorder152
https://atcoder.jp/contests/abc152/tasks

#A問題
image.png

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

int main(){
    int N,M; cin >> N >> M;
    if (N==M && N!=0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

#B問題
image.png

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

int main(){
    int a,b; cin >> a >> b;
    int tmp1=max(a,b);
    int tmp2=min(a,b);
    
    for(int i=0; i<tmp1; i++) cout << tmp2;
    return 0;
}
B問題.c++
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b; cin >> a >> b;
    int tmp1=min(a,b);
    int tmp2=max(a,b);
    string ans="";
    
    for (int i=0; i<tmp2; i++) ans+=to_string(tmp1);
    cout << ans << endl; 
}

#C問題
image.png

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

int main(){
    int N; cin >> N;
    vector <int> P(N);
    rep(i,N) cin >> P[i];
    
    ll ans=1;
    ll min=P[0];
    rep(i,N-1){
        if (min>=P[i+1]){
            ans++;
            min=P[i+1];
        }
    }
    cout << ans ;
}

#まとめ
・B問題 string ans="";としてからfor (int i=0; i<tmp2; i++) ans+=to_string(tmp1); として出力する方法忘れがち。
・C問題 minを作ることをはじめ忘れてた! 注意!

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?