답안 #975992

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975992 2024-05-06T04:48:04 Z vjudge1 Trol (COCI19_trol) C++17
0 / 50
1 ms 348 KB
#include <bits/stdc++.h>
#define nah_id_win ios_base::sync_with_stdio(0); cin.tie(0)
#define ull unsigned long long
#define int long long
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
using namespace std;
const int MOD = 1e9 + 7;

int dirx[4] = {0, -1, 0, 1};
int diry[4] = {-1, 0, 1, 0};
int dir[4] = {'L', 'U', 'R', 'D'};

void with_this_treasure_i_summon(string name){
	freopen((name + ".in").c_str(), "r", stdin); 
	freopen((name + ".out").c_str(), "w", stdout);
}

signed main(){
	nah_id_win;
	int q; cin >> q;
	while (q--){
		//cout << "query----\n";
		int l, r; cin >> l >> r;
		
		int a = l;
		while (a > 9){
			int temp = 0;
			string s = to_string(a);
			for (auto &c : s) temp += (c - '0');
			a = temp;
		}
		
		int range = r-l+1;
		int ans = (range/10) * 45;
		//cout << ans << "\n";
		range %= 9;
		ans += (range * (2*a + range-1))/2;
		
		cout << ans << "\n";
	}
}

Compilation message

trol.cpp: In function 'void with_this_treasure_i_summon(std::string)':
trol.cpp:21:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  freopen((name + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trol.cpp:22:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  freopen((name + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Incorrect 0 ms 344 KB Output isn't correct