Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits\stdc++.h>
- using namespace std;
- int t;
- void pr(long long a, int sz){
- int aa = a;
- while(a > 0){
- a /= 10;
- sz--;
- }
- for(int i = 0; i < sz; ++i){
- printf("0");
- }
- if(aa != 0)
- printf("%I64d", aa);
- }
- int main()
- {
- double l, r;
- int k;
- while(cin >> l >> r >> k && k != -1)
- {
- t++;
- long long mantisa = k * log10(r);
- double cur = 0;
- for(double it = l; it <= r; ++it)
- {
- cur += pow(10.0, k * log10(it) - (double)mantisa);
- }
- while(cur >= 1)
- {
- cur /= 10;
- mantisa++;
- }
- if(r != 0){
- printf("Case ");
- pr(t, 4);
- printf(": %.6fe", cur);
- pr(mantisa, 10);
- printf("\n");
- }
- else{
- mantisa++;
- printf("Case ");
- pr(t, 4);
- printf(": %.6fe", cur);
- pr(mantisa, 10);
- printf("\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment