結果

問題 No.2624 Prediction by Average
ユーザー Taro TanakaTaro Tanaka
提出日時 2024-02-09 21:56:00
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 4,249 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 165,024 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-28 15:12:13
合計ジャッジ時間 2,634 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#line 2 "lib/base/base.hpp"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define rep3(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define endl '\n'
#define all(v) (v).begin(),(v).end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
template <class T>
using uset = unordered_set<T>;
template <class S, class T>
using umap = unordered_map<S, T>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using gprique = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using lprique = priority_queue<T, vector<T>, less<T>>;
const int mod998 = 998244353;
const int mod107 = 1000000007;
#line 2 "lib/utility/io.hpp"
#define INT(...) \
int __VA_ARGS__; \
IN(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
IN(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
IN(__VA_ARGS__)
#define CHR(...) \
char __VA_ARGS__; \
IN(__VA_ARGS__)
#define DBL(...) \
long double __VA_ARGS__; \
IN(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
read(name)
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
read(name)
void read(int &a) { cin >> a; }
void read(long long &a) { cin >> a; }
void read(char &a) { cin >> a; }
void read(double &a) { cin >> a; }
void read(long double &a) { cin >> a; }
void read(string &a) { cin >> a; }
template <class T, class S> void read(pair<T, S> &p) { read(p.first), read(p.second); }
template <class T> void read(vector<T> &a) {for(auto &i : a) read(i);}
template <class T> void read(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
read(head);
IN(tail...);
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& A) {
os << A.first << " " << A.second;
return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& A) {
for (size_t i = 0; i < A.size(); i++) {
if(i) os << " ";
os << A[i];
}
return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& A) {
int count = 0;
os << "{";
for(auto [t, u] : A){
if(count) os << ", ";
os << t << ": " << u;
count++;
}
os << "}";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& A) {
for(auto it = A.begin(); it != A.end(); ++it){
if (it != A.begin()) os << " ";
os << (*it);
}
return os;
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& A) {
size_t count = 0;
T prev;
os << "{";
bool is_null = true, is_first = true;
for(auto it = A.begin(); it != A.end(); ++it){
if(it == A.begin()) {
is_null = false;
prev = (*it);
count = 1;
}
if (prev != (*it)){
if(!is_first) os << ", ";
is_first = false;
os << prev << ": " << count;
prev = (*it);
count = 1;
} else {
++count;
}
}
if(!is_null){
if(!is_first) os << ", ";
is_first = false;
os << prev << ": " << count;
}
os << "}";
return os;
}
void print() {
cout << "\n";
cout.flush();
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
cout << head;
if (sizeof...(Tail)) cout << " ";
print(forward<Tail>(tail)...);
}
void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"
void solve(){
double s;
ll n;
cin >> n >> s;
int si = int(10000*s);
if (si%10!=0){
if (si%10>=5) {
si += (10 - (si%10));
si /= 10;
} else {
si -= si%10;
si /= 10;
}
} else {si /= 10;}
ll count = 0;
rep3(i,1,1001){
if (i>n) break;
if ((((si+1)*i-1)/1000 - (si*i-1)/1000) >= 1) count++;
}
count += max(n - 1000LL, 0LL);
print(count);
}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t;
cin >> t;
rep(i,t) solve();
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0