/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Accepted 2ms 324.0 KiB
#3 Accepted 4ms 532.0 KiB
#4 Accepted 4ms 320.0 KiB
#5 Accepted 4ms 536.0 KiB
#6 Accepted 4ms 548.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s; cin>>s;
    int n = s.size();
    int m=0,c=0,indx=2,digit;
    bool minus_m = false,minus_c=false;
    if(s[2]=='-') {minus_m=true; indx++;}
    int i=0;
    while(s[indx]!='x')
    {
        digit = s[indx]-'0';
        m *=10;
        m += digit;
        ++indx;
    }
    ++indx;
    if(minus_m) m*= (-1);
    if(indx<n && s[indx]=='-') minus_c=true;
    ++indx;
    while(indx<n)
    {
        digit = s[indx]-'0';
        c *= 10;
        c += digit;
        ++indx;
    }
    if(minus_c) c *= (-1);
    
    int x,y;
    int q; cin>>q; while(q--)
    {
        cin>>x>>y;
        if(y==(m*x)+c) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Information

Submit By
Type
Submission
Problem
P1015 Friend in need is a friend indeed
Language
C++20 (G++ 13.2.0)
Submit At
2023-12-05 21:21:07
Judged At
2024-11-11 03:49:18
Judged By
Score
100
Total Time
4ms
Peak Memory
548.0 KiB