Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#C++, (削除) 232 (削除ここまで)(削除) 250 (削除ここまで)(削除) 228 (削除ここまで)(削除) 192 (削除ここまで) 173 characters

C++, (削除) 232 (削除ここまで)(削除) 250 (削除ここまで)(削除) 228 (削除ここまで)(削除) 192 (削除ここまで) 173 characters

#EDIT 1

EDIT 1

#EDIT 2

EDIT 2

#GOLF SCORECARD

GOLF SCORECARD

#C++, (削除) 232 (削除ここまで)(削除) 250 (削除ここまで)(削除) 228 (削除ここまで)(削除) 192 (削除ここまで) 173 characters

#EDIT 1

#EDIT 2

#GOLF SCORECARD

C++, (削除) 232 (削除ここまで)(削除) 250 (削除ここまで)(削除) 228 (削除ここまで)(削除) 192 (削除ここまで) 173 characters

EDIT 1

EDIT 2

GOLF SCORECARD

added 165 characters in body
Source Link
Wug
  • 1.7k
  • 12
  • 12

#C++, (削除) 232 (削除ここまで) (削除) 250 (削除ここまで) (削除) 228 (削除ここまで) (削除) 192 (削除ここまで) 176173 characters

#include<iostream>
int main(){long long n,x,y,i;for(std::cin>>n;n;cin>>n;n--n;){std::cin>>x>>y;i=cin>>x>>y,i=(x*2-2)*(y-2<0?0:y-2)+(y*2-2)*(x-2<0?0:x-2)<<1;x*=y;std<<1,x*=y,std::cout<<x*x-x-i<<"\n";}returni<<"\n";return 0;}
  • removed unnecessary clause: (~u>>31&(x<<1)-2) became ((x*2)-2) in 2 places, saved 16 characters (234)
  • swapped ~u>>63&u for u<0?0:u in 2 places, saving 2 characters (232)
  • swapped x-2<0?0:x-2 for u<0?0:u and removed definition of u u=x-2, in 2 places, saving 4 characters (228, shorter than original solution)
  • removed function f and moved functionality into main, saved 28 characters (200)
  • removed using namespace std; and used std::cout, std::cin, and "\n", saved 5 characters (195)
  • changed std::cin>>n;for(;n>0;--n) to for(std::cin>>n;n;--n), saved 3 characters (192)
  • removed typedef long long L; since its only used in one place now, saved 12 characters (180)
  • removed 4 parens from statements like ((x*2)-2), saved 4 characters (176)
  • removed brackets from loop by using commas instead of semicolons, compressed loop condition from std::cin>>n;n;--n to std::cin>>n;n--;, saved 3 characters (173)

#C++, (削除) 232 (削除ここまで) (削除) 250 (削除ここまで) (削除) 228 (削除ここまで) (削除) 192 (削除ここまで) 176 characters

#include<iostream>
int main(){long long n,x,y,i;for(std::cin>>n;n;--n){std::cin>>x>>y;i=(x*2-2)*(y-2<0?0:y-2)+(y*2-2)*(x-2<0?0:x-2)<<1;x*=y;std::cout<<x*x-x-i<<"\n";}return 0;}
  • removed unnecessary clause: (~u>>31&(x<<1)-2) became ((x*2)-2) in 2 places, saved 16 characters (234)
  • swapped ~u>>63&u for u<0?0:u in 2 places, saving 2 characters (232)
  • swapped x-2<0?0:x-2 for u<0?0:u and removed definition of u u=x-2, in 2 places, saving 4 characters (228, shorter than original solution)
  • removed function f and moved functionality into main, saved 28 characters (200)
  • removed using namespace std; and used std::cout, std::cin, and "\n", saved 5 characters (195)
  • changed std::cin>>n;for(;n>0;--n) to for(std::cin>>n;n;--n), saved 3 characters (192)
  • removed typedef long long L; since its only used in one place now, saved 12 characters (180)
  • removed 4 parens from statements like ((x*2)-2), saved 4 characters (176)

#C++, (削除) 232 (削除ここまで) (削除) 250 (削除ここまで) (削除) 228 (削除ここまで) (削除) 192 (削除ここまで) 173 characters

#include<iostream>
int main(){long long n,x,y,i;for(std::cin>>n;n--;)std::cin>>x>>y,i=(x*2-2)*(y-2<0?0:y-2)+(y*2-2)*(x-2<0?0:x-2)<<1,x*=y,std::cout<<x*x-x-i<<"\n";return 0;}
  • removed unnecessary clause: (~u>>31&(x<<1)-2) became ((x*2)-2) in 2 places, saved 16 characters (234)
  • swapped ~u>>63&u for u<0?0:u in 2 places, saving 2 characters (232)
  • swapped x-2<0?0:x-2 for u<0?0:u and removed definition of u u=x-2, in 2 places, saving 4 characters (228, shorter than original solution)
  • removed function f and moved functionality into main, saved 28 characters (200)
  • removed using namespace std; and used std::cout, std::cin, and "\n", saved 5 characters (195)
  • changed std::cin>>n;for(;n>0;--n) to for(std::cin>>n;n;--n), saved 3 characters (192)
  • removed typedef long long L; since its only used in one place now, saved 12 characters (180)
  • removed 4 parens from statements like ((x*2)-2), saved 4 characters (176)
  • removed brackets from loop by using commas instead of semicolons, compressed loop condition from std::cin>>n;n;--n to std::cin>>n;n--;, saved 3 characters (173)
edited body
Source Link
Wug
  • 1.7k
  • 12
  • 12
Width of board Number of positions eliminated
1 0
2 02
3 24
4 46
N 2N-42

I used my E=2N-42 formula along with the knowledge that for a board of length L, L-2 rows are viable (and thus count towards the exclusion count).

Width of board Number of positions eliminated
1 0
2 0
3 2
4 4
N 2N-4

I used my E=2N-4 formula along with the knowledge that for a board of length L, L-2 rows are viable (and thus count towards the exclusion count).

Width of board Number of positions eliminated
1 0
2 2
3 4
4 6
N 2N-2

I used my E=2N-2 formula along with the knowledge that for a board of length L, L-2 rows are viable (and thus count towards the exclusion count).

dgakdfsgd
Source Link
Wug
  • 1.7k
  • 12
  • 12
Loading
added 2357 characters in body
Source Link
Wug
  • 1.7k
  • 12
  • 12
Loading
added 86 characters in body
Source Link
Wug
  • 1.7k
  • 12
  • 12
Loading
derp. im an idiot
Source Link
Wug
  • 1.7k
  • 12
  • 12
Loading
Source Link
Wug
  • 1.7k
  • 12
  • 12
Loading

AltStyle によって変換されたページ (->オリジナル) /