Submission #26096021
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
long long n, ans;
int main() {
scanf("%lld", &n);
for (int i = 1; i <= 16; i++) {
for (int j = 0; ; j++) {
string sa(i, '1'), sb(j, '0'), sc(j, '9');
long long ta = stoll(sa + sb), tb = stoll(sa + sc);
if (ta > n)
break;
ans += min(n, tb) - ta + 1;
}
}
printf("%lld\n", ans);
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Leading 1s |
| User | nhho |
| Language | C++ (GCC 9.2.1) |
| Score | 300 |
| Code Size | 368 Byte |
| Status | AC |
| Exec Time | 8 ms |
| Memory | 3792 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:8:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
8 | scanf("%lld", &n);
| ~~~~~^~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 8 ms | 3744 KiB |
| 00-sample-002.txt | AC | 2 ms | 3792 KiB |
| 00-sample-003.txt | AC | 2 ms | 3716 KiB |
| 01-001.txt | AC | 1 ms | 3744 KiB |
| 01-002.txt | AC | 1 ms | 3756 KiB |
| 01-003.txt | AC | 3 ms | 3676 KiB |
| 01-004.txt | AC | 3 ms | 3684 KiB |
| 01-005.txt | AC | 2 ms | 3756 KiB |
| 01-006.txt | AC | 2 ms | 3704 KiB |
| 01-007.txt | AC | 2 ms | 3620 KiB |
| 01-008.txt | AC | 2 ms | 3620 KiB |
| 01-009.txt | AC | 2 ms | 3744 KiB |
| 01-010.txt | AC | 3 ms | 3680 KiB |
| 01-011.txt | AC | 3 ms | 3776 KiB |
| 01-012.txt | AC | 2 ms | 3728 KiB |
| 01-013.txt | AC | 2 ms | 3668 KiB |
| 01-014.txt | AC | 2 ms | 3684 KiB |
| 01-015.txt | AC | 2 ms | 3604 KiB |