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.

ZONeエナジー プログラミングコンテスト “HELLO SPACE” 備忘録

Posted at

結果
CとDが難易度逆という仕様。
なんでこんなことにした…
A:AC
B:AC ちょっと考えた
C:時間切れ
D:時間切れ
E:未
F:未

A - UFO襲来
ある文字列中に「ZONe」という文字列は何個あるか?
文字列12個程度なので、1個ずつ最初から数えて、あったらcount++って感じにした。

# include <bits/stdc++.h>
# include <math.h>
using namespace std;

int main() {
    string S;
    cin>>S;
    int count=0;
    for(int i=0;i<S.size()-3;i++){
        if(S.at(i)=='Z'){
            if(S.at(i+1)=='O'){
                if(S.at(i+2)=='N'){
                    if(S.at(i+3)=='e'){
                        count++;
                    }

                }
            }
        }
    }
    cout<<count<<endl;
  }

B - 友好の印

image.png
邪魔なる高さがどこか?
タワーの高さとUFO位置を結ぶ直線を引き、Y軸切片を算出。
最小となるY軸切片がタワーの一番低い狙撃ポイント答え。
y=ax+bの考えでOK。

# include <bits/stdc++.h>
# include <math.h>
using namespace std;

int main() {
    double N,D,H;
    double d[110];
    double h[110];
    double ans;
    double ansmax=0;
    cin>>N>>D>>H;
    for(int i=0;i<N;i++){
        cin>>d[i]>>h[i];
        if(h[i]>((H/D)*d[i])){
            ans=((D*h[i])-(H*d[i]))/(D-d[i]);
            if(ans>ansmax){
            ansmax=ans;
            }
        }
    }
    if(ans==0){
        cout<<"0.0"<<endl;
    }
    else{
    cout<<ansmax<<endl;
    }
  }
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?