1790A: Polycarp and the Day of Pi

Simple implementation problem. Find the number of digits from the front of s that match digits from pi.


_25
#include <iostream>
_25
#include <string>
_25
_25
constexpr std::string_view kDigitsOfPi = "314159265358979323846264338327";
_25
_25
void solve() {
_25
std::string s;
_25
std::cin >> s;
_25
for (int i = 0; i < kDigitsOfPi.length(); ++i) {
_25
if (s[i]!=kDigitsOfPi[i]) {
_25
std::cout << i << '\n';
_25
return;
_25
}
_25
}
_25
std::cout << "30\n";
_25
}
_25
_25
int main() {
_25
int t;
_25
std::cin >> t;
_25
for (int tc = 1; tc <= t; ++tc) {
_25
solve();
_25
}
_25
return 0;
_25
}

If you found this solution helpful, consider leaving a star!